Position over a sphere

Some time ago, I was trying to move a camera (in 3D space) around the player, which ultimately is about moving an object around a sphere.

Now, the equation for the position around a circle is pretty easy and is:

However, I needed equations to find the position over a sphere.

A POINT IN 3D SPACE, DEFINED BY TWO ANGLES AND A DISTANCE FROM THE ORIGIN.

After some research and trial and error, I came up with this solution:

 Observations:

  • longitude is the angle around the Y axis.
  • latitude is the angle around the X and Z axis.
  • sphereCenter defines the position of the object we will be moving around.

I hope this will be handy to anyone trying to figure out how to move over a sphere.

Leave a Reply