-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex_moebius.py
More file actions
34 lines (28 loc) · 1.07 KB
/
ex_moebius.py
File metadata and controls
34 lines (28 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
""" ex_moebius.py - define a Moebius strip point cloud
Define a Moebius strip pointcloud
"""
import numpy as np
def moebius_strip( nu=800, nv=100 ):
""" Return a Moebius strip point cloud
Return a numpy array with shape [nu*nv, 3] containing floating point coordinates
of a Moebius strip. See also: http://en.wikipedia.org/wiki/Moebius_strip
Optional arguments:
nu = discretization of the u parameter (should be about 8*nv)
nv = discretization of the v parameter
"""
urange = [ 0.0, 2.0*np.pi ]
vrange = [ 0.0, 2.0 ]
ustep = (urange[1]-urange[0])/float(nu)
vstep = (vrange[1]-vrange[0])/float(nv)
i, u = 0, 0.0
points = np.empty([nu*nv, 3])
for _ in xrange(nu):
v = -1.0
for _ in xrange(nv):
points[i,0] = ( 1.0+(v/2.0)*np.cos(u/2.0) ) * np.cos(u);
points[i,1] = ( 1.0+(v/2.0)*np.cos(u/2.0) ) * np.sin(u);
points[i,2] = (v/2.0) * np.sin(u/2.0);
v += vstep
i += 1
u += ustep
return points