-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSphere.py
More file actions
61 lines (48 loc) · 1.31 KB
/
Sphere.py
File metadata and controls
61 lines (48 loc) · 1.31 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
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
import math
class Sphere:
radius = float()
Ao = float()
volume = float()
error = False
def getValues(self):
if self.error != True:
if self.radius:
self.radToAoV()
elif self.Ao:
self.AoToRV()
else:
self.vToRAo()
finalValues = {
'r': self.radius,
'Ao': self.Ao,
'V': self.volume
}
else:
finalValues = {
'ERROR': 0
}
self.resetValues()
return finalValues
def radToAoV(self):
radius = self.radius
volume = (4/3) * (radius ** 3.0) * math.pi
area = 4 * (radius ** 2) * math.pi
self.volume = volume
self.Ao = area
def vToRAo(self):
V = self.volume
radius = ((3 * V) / (4 * math.pi)) ** (1/3)
area = 4 * math.pi * (radius ** 2)
self.radius = radius
self.Ao = area
def AoToRV(self):
Ao = self.Ao
radius = (Ao / (4 * math.pi)) ** (1/2)
volume = (4/3) * math.pi * (radius ** 3)
self.radius = radius
self.volume = volume
def resetValues(self):
self.radius = float()
self.Ao = float()
self.volume = float()
self.error = False