-
Notifications
You must be signed in to change notification settings - Fork 2
/
cvf.py
84 lines (58 loc) · 2.1 KB
/
cvf.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import json
def rad2deg(theta):
if theta > 2 * 3.14159265358:
return rad2deg(theta - 2 * 3.14159265358)
if theta < 0.0:
return rad2deg(theta + 2 * 3.14159265358)
return theta * 180 / 3.14159265358
def deg2rad(theta):
if theta > 360.0:
return deg2rad(theta - 360)
if theta < 0.0:
return deg2rad(theta + 360)
return theta * 3.14159265358 / 180
class cvf(object):
def getX(self):
return self.inputJson['camera']['position']['x']
def getY(self):
return self.inputJson['camera']['position']['y']
def getZ(self):
return self.inputJson['camera']['position']['z']
def getPitch(self):
return self.inputJson['camera']['orientation']['pitch']
def getYaw(self):
return self.inputJson['camera']['orientation']['yaw']
def getSunAltitude(self):
return self.inputJson['sun']['altitude']
def getSunAzimuth(self):
return self.inputJson['sun']['azimuth']
def getSunIntensity(self):
return self.inputJson['sun']['intensity']
def setX(self, fl):
self.inputJson['camera']['position']['x'] = fl
def setY(self, fl):
self.inputJson['camera']['position']['y'] = fl
def setZ(self, fl):
self.inputJson['camera']['position']['z'] = fl
def setYaw(self, flr):
fl = deg2rad(flr)
self.inputJson['camera']['orientation']['yaw'] = fl
def setPitch(self, flr):
fl = deg2rad(flr)
self.inputJson['camera']['orientation']['pitch'] = fl
def setSunAltitude(self, fl):
self.inputJson['sun']['altitude'] = fl
def setSunAzimuth(self, fl):
self.inputJson['sun']['azimuth'] = fl
def setSunIntensity(self, fl):
self.inputJson['sun']['intensity'] = fl
def setName(self, f):
self.filename = f
self.inputJson['name'] = f
def saveToFile(self, filename):
with open(filename, 'w+') as f:
json.dump(self.inputJson, f)
def __init__(self, name):
self.filename = name
inputJsonString = open(name).read()
self.inputJson = json.loads(inputJsonString)