Lines from Surface VerticesΒΆ

../../_images/line_surf_vert.png
import copy
import numpy as np
import matplotlib.pyplot as plt
import s3dlib.surface as s3d

#.. Lines from Surface Vertices

# 2. Setup and map surfaces .........................................

surface = s3d.SphericalSurface.platonic(0, 'dodeca')

# inner & outer surface edges .........................
edges = surface.edges
edges2 = copy.copy(edges).transform(scale=0.5)
edges.set_color('r')
edges2.set_color('b')

# lines from inner to outer surface vertices ..........
totVerCoor = np.append(edges.vertexCoor,edges2.vertexCoor,axis=0)
n = len(edges.vertexCoor)
frstIndx = np.arange(0,n,1)
segIndx = np.array([frstIndx,frstIndx+n]).T
line = s3d.ColorLine3DCollection(totVerCoor,segIndx,cmap='rainbow').shred(6)
line.map_cmap_from_op(lambda c : s3d.SphericalSurface.coor_convert(c)[0])

# total set of lines .................................
tot_lines = edges + edges2 + line
tot_lines.set_linewidth(3)

# 3. Construct figure, add surface, and plot ......................

minmax = (-0.7,0.7)
fig = plt.figure(figsize=(4,4))
ax = plt.axes(projection='3d', aspect='equal')
ax.set(xlim=minmax, ylim=minmax, zlim=minmax)
ax.set_axis_off()
ax.set_proj_type('ortho')
ax.view_init(35,-70)

ax.add_collection3d(tot_lines.fade())

fig.tight_layout(pad=1)
plt.show()