Jump to content
  • Advertisement
Sign in to follow this  

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.

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
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);

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

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

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.

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!