-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sphere_def.py
156 lines (96 loc) · 2.9 KB
/
Sphere_def.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import numpy as np
def Sphere0():
mm = 1 #theta
stepii = 30
nn = 360 #phi
stepjj = 1
C0 = np.zeros((3, nn))
for ii in range(mm):
theta1 = stepii * ii
for jj in range(nn):
phi1 = stepjj * jj
x1 = 0
y1 = np.cos(phi1 * np.pi/180)
z1 = np.sin(phi1 * np.pi/180)
C0[0,jj] = x1
C0[1,jj] = y1
C0[2,jj] = z1
return C0
def Sphere45():
mm = 1 #theta
stepii = 30
nn = 360 #phi
stepjj = 1
C45 = np.zeros((3, nn))
for ii in range(mm):
theta1 = 45
for jj in range(nn):
phi1 = stepjj * jj
x1 = 0
y1 = np.cos(phi1 * np.pi/180)
z1 = np.sin(phi1 * np.pi/180)
# Rotate 90 degree in XY plane
x2 = np.cos(theta1*np.pi/180)*x1 - np.sin(theta1*np.pi/180)*y1
y2 = np.sin(theta1*np.pi/180)*x1 + np.cos(theta1*np.pi/180)*y1
z2 = z1
C45[0,jj] = x2
C45[1,jj] = y2
C45[2,jj] = z2
return C45
def Sphere90():
mm = 1 #theta
stepii = 30
nn = 360 #phi
stepjj = 1
C90 = np.zeros((3, nn))
for ii in range(mm):
theta1 = 90
for jj in range(nn):
phi1 = stepjj * jj
x1 = 0
y1 = np.cos(phi1 * np.pi/180)
z1 = np.sin(phi1 * np.pi/180)
# Rotate 90 degree in XY plane
x2 = np.cos(theta1*np.pi/180)*x1 - np.sin(theta1*np.pi/180)*y1
y2 = np.sin(theta1*np.pi/180)*x1 + np.cos(theta1*np.pi/180)*y1
z2 = z1
C90[0,jj] = x2
C90[1,jj] = y2
C90[2,jj] = z2
return C90
def Sphere135():
mm = 1 #theta
stepii = 30
nn = 360 #phi
stepjj = 1
C135 = np.zeros((3, nn))
for ii in range(mm):
theta1 = 135
for jj in range(nn):
phi1 = stepjj * jj
x1 = 0
y1 = np.cos(phi1 * np.pi/180)
z1 = np.sin(phi1 * np.pi/180)
# Rotate 90 degree in XY plane
x2 = np.cos(theta1*np.pi/180)*x1 - np.sin(theta1*np.pi/180)*y1
y2 = np.sin(theta1*np.pi/180)*x1 + np.cos(theta1*np.pi/180)*y1
z2 = z1
C135[0,jj] = x2
C135[1,jj] = y2
C135[2,jj] = z2
return C135
def SphereH0():
mm = 1 #theta
stepii = 30
nn = 360 #phi
stepjj = 1
H0 = np.zeros((3, nn))
for jj in range(nn):
phi1 = stepjj * jj
x1 = np.cos(phi1 * np.pi/180)
y1 = np.sin(phi1 * np.pi/180)
z1 = 0
H0[0,jj] = x1
H0[1,jj] = y1
H0[2,jj] = z1
return H0