r = tw.radius(theta)
return cos(zeta) * r + sin(zeta) * tw._axis
+class DiscreteBezier():
+ def __init__(b, cp, nt, bezier_constructor=DoubleCubicBezier):
+ b.nt = nt
+ b._t_vals = np.linspace(0, 1, b.nt+1)
+ b._continuous_bezier = bezier_constructor(cp)
+ def point_at_it(b, it):
+ t = b._t_vals[it]
+ return b._continuous_bezier.point_at_t(t)
+
class MoebiusHalf:
def __init__(m, nu, nt):
'''
m.nt = nt
m._thetas = [ u * tau for u in np.linspace(0, 1, nu+1) ]
m._cp2b = BezierSegment([ (c,) for c in [0.33,0.33, 1.50]])
- m._beziers = [ m._bezier(theta) for theta in m._thetas ]
- m._t_vals = np.linspace(0, 1, m.nt+1)
- def _bezier(m, theta, constructor=DoubleCubicBezier):
+ m._dbeziers = [ m._dbezier(theta) for theta in m._thetas ]
+ def _dbezier(m, theta, dconstructor=DiscreteBezier):
cp = [None] * 4
cp[0] = m.edge .point(theta)
cp[3] = m.midline.point(theta*2)
# file=sys.stderr)
cp[1] = cp[0] + cp1scale * m.edge .dirn (theta)
cp[2] = cp[3] + cp2scale * m.midline.dirn (theta*2)
- return constructor(cp)
+ return dconstructor(cp, m.nt)
def point(m, iu, it):
'''
0 <= iu <= nu meaning 0 <= u <= 1
0 <= it <= nt across the half-traverse
0 is the edge, 1 is the midline
'''
- t = m._t_vals[it]
- return np.array(m._beziers[iu].point_at_t(t))
+ return np.array(m._dbeziers[iu].point_at_it(it))
def details(m, iu, t):
'''