File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 1151
1151
unit radius sphere on the origin is:
1152
1152
1153
1153
$$ x = \cos(\phi) \cos(\theta) $$
1154
- $$ y = \sin(\phi) \cos(\theta) $$
1155
- $$ z = \sin(\theta) $$
1154
+ $$ z = \sin(\phi) \cos(\theta) $$
1155
+ $$ y = \sin(\theta) $$
1156
1156
</ div>
1157
1157
1158
1158
< div class='together'>
1159
1159
We need to invert that. Because of the lovely `< cmath> ` function `atan2()` which takes any number
1160
- proportional to sine and cosine and returns the angle, we can pass in $x $ and $y $ (the
1160
+ proportional to sine and cosine and returns the angle, we can pass in $z $ and $x $ (the
1161
1161
$\cos(\theta)$ cancel):
1162
1162
1163
- $$ \phi = \text{atan2}(y , x) $$
1163
+ $$ \phi = \text{atan2}(z , x) $$
1164
1164
</ div>
1165
1165
1166
1166
< div class='together'>
1167
1167
The $atan2$ returns values in the range $-\pi$ to $\pi$, so we need to take a little care there.
1168
1168
The $\theta$ is more straightforward:
1169
1169
1170
- $$ \theta = \text{asin}(z ) $$
1170
+ $$ \theta = \text{asin}(y ) $$
1171
1171
1172
1172
which returns numbers in the range $-\pi/2$ to $\pi/2$.
1173
1173
</ div>
You can’t perform that action at this time.
0 commit comments