Jump to content
  • Advertisement
Sign in to follow this  
angrybob

OpenGL Confused by Quaternions

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

Hi, I'm thinking about using quaternions to do my rotations but I haven't found any really useful tutorials on how to use them. Most simply tell you all the operators you can apply to the and so on. I'd appreciate it if you guys could clear up some issues I've got: 1) What should I initialise my quaternion to so that it represents no rotation.. Anything with the "real" part set to zero right? 2) One thing I want to achieve is this: given an object with a certain rotation (represented by a quaternion), I want to be able to rotate it so it faces towards another object.. how do I do this? I'd like to be able to do part 2 in two ways, first simply set the rotation so the object exactly faces another object and second gradualy update the orientation of my object so it will rotate to be facing another object after a a few frames. To do this whole facing another object thing I need some notion of what is forward for that object.. but that is effectively encoded in the quaternion right? since the default (in opengl) of no rotation leaves things pointing down the negative z axis.. right?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by angrybob
1) What should I initialise my quaternion to so that it represents no rotation.. Anything with the "real" part set to zero right?


Identity quaternion is represented by q = (1, (0, 0, 0)).It simply represents no angular displacement. Numbers in bold mean that they are components of the vector.

Quote:

2) One thing I want to achieve is this: given an object with a certain rotation (represented by a quaternion), I want to be able to rotate it so it faces towards another object.. how do I do this?


Hmmm... There is something I don't really understand here. What do you mean by 'facing towards another object'? Do you mean that you'd like to interpolate beetwen two angles represented by quaternions? If so, you should look for technique called 'Slerp' (spehrical linear interpolation) or 'Squad'. These topics require at least some principial understandment of quaternion maths. If you are not familiar with it, you'd have to google for some tutorials or get your self a book (like "3D Math Primer (...)").

Hope it helps! :)

--------------

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!