Functional Closed SurfaceΒΆ

The Multiple Geometric Maps example surface.

../../_images/blender_knot.png
import numpy as np
import s3dlib.surface as s3d

#.. Functional Cloed Surface

# 1. Define functions to examine ....................................

def torusFunc(rtz) :
    r,t,z = rtz
    ratio = .2
    Z = ratio*np.sin(z*np.pi)
    R = r + ratio*np.cos(z*np.pi)
    return R,t,Z

def knot(rtz) :
    r,t,z = rtz
    R = r*( (1+np.cos(5*t))/2 + 0.65*(1+np.cos(np.pi + 5*t))/2 )
    Z = z +  0.25*np.sin(5*t)
    return R,2*t,Z

# 2. Setup and map surfaces .........................................
rez = 5

torus = s3d.CylindricalSurface(rez)
torus.map_geom_from_op( torusFunc )
torus.map_geom_from_op( knot )

s3d.save_surfgeom_to_obj('obj_files/knot_surface.obj',torus)