# Rotation in a sphere

## Recommended Posts

I would like the player to be walking inside of a sphere, so the controls of the camera and the movement are relative to the position in the sphere. I already imlemented the gravity but I am having trouble with the rotation and controls of the camera.

##### Share on other sites

(Disclaimer: just woke up)

Looks like what you want is the tangent of the circle at the point where the player is.

This should be just orthogonal to the gravity vector you already have.

##### Share on other sites

I'll make the sphere centered at the origin and with radius 1, for simplicity. Your position on the sphere is a unit-length vector, and your forward direction is another unit-length vector which is perpendicular to the position vector. That's the whole state. It's also handy to have a side direction, which can be computed as the cross-product of the other two vectors. You can move by adding a small multiple of the forward direction or the side direction to the current position. You can then renormalize the position (project back to the surface of the sphere, so you don't walk on a tangent) and use the Gram-Schmidt process to adjust the forward and side vectors.

From the position, forward and side vectors, you should have all you need to set up the camera.

## Create an account

Register a new account

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633769
• Total Posts
3013759
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!