Jump to content
  • Advertisement
Sign in to follow this  
CAPE

Checking the rotation of a object moving around on a sphere

This topic is 4251 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

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 this post


Link to post
Share on other sites
Advertisement
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.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!