# Walking on a sphere

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

## Recommended Posts

Hello,

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 on other sites
We actually discussed this same question recently. See here. (And ditch the spherical coordinates; just use a point in 3-space.)

##### Share on other sites
Quote:
 Original post by EmergentWe 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 on other sites
Probably
point_on_sphere = center_of_sphere + radius_of_sphere * normal
assuming that the normal is of unit length.

##### Share on other sites
Got it,
Thanks for pointing me in the right direction guys.