Composite SurfaceΒΆ
The Spirals example surface.
import numpy as np
import s3dlib.surface as s3d
#.. influenced by M.C.Escher - Spirals obj output
#.. https://mcescher.com/gallery/mathematical/
# 1. Define function to examine .....................................
def twisted_torus(rtz,rotate) :
twists, width, radMax, radMin, stretch = 5, 0.125, 0.70, 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,1000,'s')
t.map_geom_from_op( lambda rtz : twisted_torus(rtz,rot) )
if i is 0 : surface = t
else : surface += t
s3d.save_surfgeom_to_obj('obj_files/spirals.obj',surface)