Klein BottleΒΆ
The Klein Bottle, Spherical to XYZ example surface.
import numpy as np
import s3dlib.surface as s3d
#.. Klein Bottle obj export
# 1. Define function to examine ....................................
def klein(rtp) :
r,t,p = rtp
u = p
v = t
cU, sU = np.cos(u), np.sin(u)
cV, sV = np.cos(v), np.sin(v)
x = -(2/15)*cU* \
( ( 3 )*cV + \
( -30 + 90*np.power(cU,4) - 60*np.power(cU,6) + 5*cU*cV )*sU \
)
y = -(1/15)*sU* \
( ( 3 - 3*np.power(cU,2) -48*np.power(cU,4) +48*np.power(cU,6) )*cV + \
(-60 + ( 5*cU - 5*np.power(cU,3) - 80*np.power(cU,5) + 80*np.power(cU,7) )*cV )*sU \
)
z = (2/15)*( 3 + 5*cU*sU )*sV
return x,y,z
# 2. Setup and map surface .........................................
rez=6
surface = s3d.SphericalSurface(rez,basetype='octa_c')
surface.map_geom_from_op( klein, returnxyz=True )
surface.transform(s3d.eulerRot(0,-90),translate=[0,0,2])
s3d.save_surfgeom_to_obj('obj_files/klein_bottle.obj',surface)