# Checking the rotation of a object moving around on a sphere

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

## Recommended Posts

Well, it was quite a long topic name, but maybe i chaught someones interest :). So, i got quite a matrix rotation problem here. I´m using ODE physics to make a round sphere that should work like a globe with it´s own gravity. Well, the gravity shit works fine (maybe not the collision, but it´s there :P). Now to my question. When my object starts i have good knowing about the rotation, but i can´t figure out how I´m supposed to update my up, at, right vectors when i start moving around, resulting in quite disturbing (but funny) movments. And as all things, standing upright is the way to go. So, somehow, I would like to have my object standing straight from the ground wherever i go on the globe. So, is there anyone that maybe have tried anything like this and could please share their knowledge in the subject. PS. Like you problaly already guessed, I´m no math pro, so please no fancy words without any describing coming along.

##### Share on other sites
Sounds like you want to work in spherical coordinates .

##### Share on other sites
the Up is easy, it's just the direction from the centre of the sphere to your position, normalised.

as for the rest, what you can do is just take your current vectors and re-arrange them so they give a nice orthonormal orientation matrix.

// up vector
Up = (Position - PlanetCentre);
Up.Normalise();

// 'side' vector
StrafeVector = UpVector.CrossProduct(ForwardVector);
StrafeVector.Normalise();

// 'Direction' vector
ForwardVector = StrafeVector.CrossProduct(UpVector);
ForwardVector.Normalise();

The third normalisation may not be necessary (can't remember for sure).

Then to make a matrix out of these vectors, that should just be a matter of filling the rows and columns with those three vectors.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633709
• Total Posts
3013481
×