-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathcreate_viewpoints.py
executable file
·39 lines (35 loc) · 1.38 KB
/
create_viewpoints.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
# This script is to create 20 viewpoints (vertices of a regular dodecahedron) around shapes.
import math
if __name__ == '__main__':
phi = (1 + math.sqrt(5)) / 2. # golden_ratio
circumradius = math.sqrt(3)
distance = circumradius*1.2
dodecahedron = [[-1, -1, -1],
[ 1, -1, -1],
[ 1, 1, -1],
[-1, 1, -1],
[-1, -1, 1],
[ 1, -1, 1],
[ 1, 1, 1],
[-1, 1, 1],
[0, -phi, -1 / phi],
[0, -phi, 1 / phi],
[0, phi, -1 / phi],
[0, phi, 1 / phi],
[-1 / phi, 0, -phi],
[-1 / phi, 0, phi],
[ 1 / phi, 0, -phi],
[ 1 / phi, 0, phi],
[-phi, -1 / phi, 0],
[-phi, 1 / phi, 0],
[ phi, -1 / phi, 0],
[ phi, 1 / phi, 0]]
# get Azimuth, Elevation angles
# Azimuth varies from -pi to pi
# Elevation from -pi/2 to pi/2
view_points = open('./view_points.txt', 'w+')
for vertice in dodecahedron:
elevation = math.asin(vertice[2] / circumradius)
azimuth = math.atan2(vertice[1], vertice[0])
view_points.write('%f %f %f %f\n' % (azimuth, elevation, 0., distance))
view_points.close()