Skip to content

Instantly share code, notes, and snippets.

@Kaminate
Created August 6, 2013 06:07
Show Gist options
  • Save Kaminate/6162417 to your computer and use it in GitHub Desktop.
Save Kaminate/6162417 to your computer and use it in GitHub Desktop.
How Spherical Coordinates work (no pictures, sorry)
say you have a coordinate system
x axis
y axis
z axis
and a vector v
if you think of the coordinates as a vector (say x) and a plane (say yz)
v makes a half-angle alpha [0,180] with x
v makes a full-angle beta [0,90] with yz
r is the length of v (r stands for radius)
v.x = rcos(alpha)
v.y = rsin(alpha)cos(beta)
v.z = rsin(alpha)sin(beta)
when alpha == 0, v is aligned with the x axis.
because of this, v.y and v.z need to be 0 when alpha is 0.
In order to make this true, we put sin(alpha) as part of v.y and v.z
because sin(0) = 0
r = sqrt(v.x * v.x + v.y * v.y + v.z * v.z)
alpha = acos(v.x/r)
beta = atan(v.z / v.y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment