Sign in to follow this  

Walking on a sphere

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this