SpiralsΒΆ
This surface object is composed of four twisted cylindrical grid surfaces.
REOM: 1
import numpy as np
from matplotlib import pyplot as plt
import s3dlib.surface as s3d
#.. influenced by M.C.Escher - Spirals
#.. https://mcescher.com/gallery/mathematical/
# 1. Define function to examine .....................................
scolor,ttlcolor = [0.859, 0.788, 0.729], [0.502, 0.200, 0.278, 0.1]
fgbgcolor,gbcolor = [0.867, 0.800, 0.729], [0.506, 0.482, 0.435]
elev, azim, illum = 30,30, [0,-1,1 ]
def twisted_torus(rtz,rotate) :
twists, width, radMax, radMin, stretch = 5, 0.125, 0.6, 0.05, 1.4
r,t,z = rtz
phi = t*twists + rotate*2*np.pi + np.pi/4.0
ratio = radMax - t*(radMax-radMin)/(2.0*np.pi)
R = r + ratio*np.cos(z*width*np.pi+phi)
T = t*stretch
Z = ratio*np.sin(z*width*np.pi+phi)
return R,T,Z
# 2. Setup and map surfaces .........................................
rotation = [0.00, 0.25, 0.50, 0.75]
for i,rot in enumerate(rotation) :
t = s3d.CylindricalSurface.grid(50,500,'s',color=scolor )
t.map_geom_from_op( lambda rtz : twisted_torus(rtz,rot) )
surface = t if i == 0 else surface + t
surface.transform(translate=[.3,0,0])
# 3. Construct figure, add surface, plot ............................
fig = plt.figure(figsize=(5,5) , facecolor=fgbgcolor)
text = fig.text(0.97, 0.5, 'S3Dlib.org', color=ttlcolor, ha='right',
va='center', rotation=90, fontsize=45, fontweight='bold' )
fig.text(0.11,0.12,str(surface),color=scolor ,fontsize='x-small')
ax = plt.axes(projection='3d', facecolor=gbcolor)
ax.set(xlim=(-1,1), ylim=(-1,1), zlim=(-1,1) )
ax.set_axis_off()
ax.view_init(elev, azim)
surface.shade( direction=illum,ax=ax,rview=True)
surface.hilite(.5,direction=illum,ax=ax,rview=True)
ax.add_collection3d(surface)
fig.tight_layout(pad=3)
plt.show()
