Jump to content
  • Advertisement
Sign in to follow this  

Walking on a sphere

This topic is 2807 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I'm making a game where the players are on a sphere world and can walk around as one would expect them to.

The problem I'm having is finding out the position on the sphere the players would go to when they step forwards/backwards or strafe.

Essentially I need to calculate relative azimuth and inclination angles of a point in the direction the player is looking.

I've had a few ideas but I've hit dead ends on each.
If you could help me out or let me know what the relevant equations are that would be super.

At the moment I calculate a 'look at' point based on an x-angle and y-angle that increases or decreases when the player moves the mouse. The 'look at' point is found by putting an imaginary sphere around the player and using the x and y angles as azimuth and inclination with an arbitrary radius. (described well on this wiki page.)

lookX = 10 * sin(YAng) * cos(XAng);
lookY = 10 * cos(YAng);
lookZ = 10 * sin(YAng) * sin(XAng);

One idea I had for forward motion is to imagine a line from the center of the planet to the 'look at' point (with a radius proportional to walking speed) and check when it intercepts the spheres surface.

For that approach I couldn't find out how to find the intercept point of the line, I imagine it shouldn't be too hard because the sphere has a set radius.

Any guidance would be much appreciated.

Share this post

Link to post
Share on other sites
Original post by Emergent
We actually discussed this same question recently. See here. (And ditch the spherical coordinates; just use a point in 3-space.)

Ok, thanks,

I have just one question, in that thread; jyk's second step mentions "[computing] the point on the surface from the normal and the sphere radius".

What is the operation to do this?
I have the normal and the radius of the sphere.

Thank you!

Share this post

Link to post
Share on other sites
point_on_sphere = center_of_sphere + radius_of_sphere * normal
assuming that the normal is of unit length.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!