# OpenGL Confused by Quaternions

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

## 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 on other sites
Quote:
 Original post by angrybob1) 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! :)

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

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5

• 14
• 9
• 10
• 12
• 17
• ### Forum Statistics

• Total Topics
632910
• Total Posts
3009174
• ### Who's Online (See full list)

There are no registered users currently online

×