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 = [0.859, 0.788, 0.729]
gbcolor = [0.506, 0.482, 0.435]
ttlcolor = [0.502, 0.200, 0.278, 0.1]
fgbgcolor = [0.867, 0.800, 0.729]
elev, azim = 30,30
illum = [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
ratio = radMax - t*(radMax-radMin)/(2.0*np.pi)
phi =t*twists + rotate*2*np.pi + np.pi/4.0
z = width*z
Z = ratio*np.sin(z*np.pi+phi)
R = r + ratio*np.cos(z*np.pi+phi)
T = t*stretch
return R,T,Z
# 2. Setup and map surfaces .........................................
surface = None
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) )
if i == 0 : surface = t
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' )
minmax = ( -1,1 )
ax.set(xlim=minmax, ylim=minmax, zlim=minmax )
ax.set_axis_off()
ax.view_init(elev, azim)
ax.set_facecolor(gbcolor)
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()