##
# Klein bottle
# p01 2010
# Maya python script
##
from math import sin, cos, pi
from maya.cmds import curve, ls, loft, delete
rad = 1
uRes = .1
vRes = .1
cvs = []
u = -pi
while u <= pi :
pts = []
v = -pi
while v <= pi :
x = cos(u) * (rad + sin(v) * cos(u/2) - sin(2*v) * sin(u/2)/2)
y = sin(u) * (rad + sin(v) * cos(u/2) - sin(2*v) * sin(u/2)/2)
z = sin(u/2) * sin(v) + cos(u/2) * sin(2*v)/2
pts.append((x, y, z))
v += vRes
u += uRes
curve(p=pts)
cv = ls(sl=1)
cvs.append(cv[0])
loft(cvs)
delete(cvs)