-
Notifications
You must be signed in to change notification settings - Fork 1
/
runExamples3D.py
42 lines (31 loc) · 1.66 KB
/
runExamples3D.py
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
35
36
37
38
39
40
41
42
from ChebyshevObject3D import *
if __name__== '__main__':
outputPrefix = 'demo3D_'
e = 1.0
sites = np.random.rand(3**3, 3) * 2 * e - e
# random sites axis aligned and randomly oriented
aniFun = None
for tag, oriFun in zip(['axisAligned', 'random'], [None, lambda xyzs: np.random.rand(len(xyzs), 3) * np.pi - np.pi/2]):
cObj = ChebyshevObject3D(sites, oriFun, aniFun, e, tag = tag)
cObj.computeDiagram()
cObj.plot(withCentroids=False, withInitCells=False, withBBs=False)
cObj.exportToObj(outputPrefix + tag + '.obj')
# provoke cells of higher genus on tailored input
# with axis aligned and rotated sites
sites = np.float32([[-1,0,0],[0,0,0],[1,0,0]]) * 0.25
def aniFun(xyzs): return np.tile([[1,2,1],[2,2,2],[1,1,2]], [1,2])
for m, oriFun in zip(['AxisAligned', 'Rotated'], [None, lambda xyzs: np.float32([[0.25,0,0],[0,0,0],[0.25,0,0]]) * np.pi]):
tag = 'genus'+m
cObj = ChebyshevObject3D(sites, oriFun, aniFun, e, withMP = False, tag = tag)
cObj.computeDiagram()
cObj.exportToObj(outputPrefix + tag + '.obj')
# wavy orientation field and anisotropic scaling
# load relaxed CVT sites from file
def oriFun(xyzs): return np.transpose(np.vstack([np.zeros((2,len(xyzs))), np.pi/2 - (1+np.cos(np.pi * xyzs[:,0])) * np.pi/20]))
def aniFun(xyzs): return np.tile(((2-np.abs(xyzs[:,0])) * [[0],[1],[0]]).T + [1,0,1], [1,2])
for m in '2i':
tag = 'wavyL'+m
sites = np.load('data/sitesL%s.npz'%m)['sites']
cObj = ChebyshevObject3D(sites, oriFun, aniFun, e, tag = tag)
cObj.computeDiagram()
cObj.exportToObj(outputPrefix + tag + ".obj")