# Rotating wiht Quaternion

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

## Recommended Posts

So I have this small problem that I don't understand. I have an object that I want to rotate around it's Y-axis (regardless of the direction it's looking at) every frame. With me limited knowledg of quaternion I thought that this idea would work. 1- Get the quaternion for the object (objQuat) 2- Create a quaternion that rotates around the Y-axis with a certain degree/second (rotatQuat). Where x = 0, y = 1, z = 0, angleSpeed = how fast I want the object to rotate, and deltaTime = time diffrence between this frame and the last frame. So rotateQuat = Quaternion(x, y, z, angleSpeed * deltaTime). 3- I multiply both quaternion to get the direction I want (resutlQuat = objQuat * rotateQuat) I tested and it sort of worked. The object only rotates for like 180 degrees. It stops half way. I can rotate it back but it stops at it's first position. Can someone exmplin why is this happing? And how to solve it? Cheers :)

##### Share on other sites
A quaternion isn't just a straight axis-angle pair; it's slightly more complicated than that. Given a (normalized) axis (x,y,z) and an angle of rotation, the corresponding quat is:

Q = ( x*sin(angle/2), y*sin(angle/2), z*sin(angle/2), cos(angle/2) )

So in your case you want:

rotateQuat = Quaternion( 0, sin(angleSpeed*deltaTime / 2), 0, cos(angleSpeed * deltaTime / 2) )

##### Share on other sites
Yes, actually, I know that. The quaternion I use do that, just didn't want to make a long post :P Sorry if that wasn't clear.

I'm still wondering why this is happing. I used this method for some effects and worked, but I never used it to make a full 360 degree before. I was just surprised that it didn't work.

Any one else?

1. 1
2. 2
3. 3
4. 4
Rutin
13
5. 5

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

• Total Topics
633696
• Total Posts
3013394
×