Skip to main content
gamedev.net
🔒 Locked

quats - difference

Started by supagu 2 replies 700+ views
Original Post
supagu
supagu
lets say i have 2 quats. one having 0 degrees (x,y,z,w) = (0, 0, 0, 1) the other having 90 degrees (x,y,z,w) = (0, 0.7, 0, 0.7) i want to adjust the 90 degree quat by the 0 degree quat. should i simply take one from the other? this results in: (0, 0.7, 0, 0.7) - (0, 0, 0, 1) = (0, 0.7, 0, -0.3) is this right? i would expect somehow to get the same quat out ie. (0, 0.7, 0, 0.7). the reason im doing this is i have an animation that may be say 90 degrees from what i want, so i need to adjust any quats from the animation by 90 degrees for example. ideas is subtraction is what i should be using for this?
SiCrane
SiCrane
By adjust, do you mean concatenate? If so, then to do quaternion concatenation, you multiply the the quaternions together.
supagu
supagu
no. lets say i have an angle of 140 degrees, but its 90 degrees out, i would do 140 - 90 = 50 degrees.
similarly i have a quat thats 90 degrees out, can i just do a difference?

i've tested it and it seems okay, might need to normalise it though after as i get some stretching occuring in my animations :-/

edit: normalizing seems to change the angle to be smaller than expected but stops the stretching (ie. non-normalized gives correct angle, but results in stretching, normalize gives wrong angle, but there is no stretching)

[Edited by - supagu on December 21, 2004 8:23:51 PM]
Zakwayda
Zakwayda
Quaternion subtraction isn't what you want here (it's not a particularly useful operation in any case).

I would say that you need either quaternion multiplication (as SiCrane suggested), or slerp, depending on what you're trying to do.

Let's say you have a quaternion that represents a 45 degrees rotation about the y axis, and you want to rotate *from that orientation* by an additional 15 degrees. To do so, construct a quaternion representing a 15 degree rotation about the y axis, and multiply it by your original quaternion. The resulting quaternion should represent a rotation of 60 degrees about the y axis.

On the other hand, say you have two quaternions representing rotations of 45 and 90 degrees, respectively, about the y axis. You can get from one to the other, either instantaneously or in increments, using an algorithm known as 'slerp'. If you're not familiar with this algorithm, a google search or search of this forum's archives should help you out.

I hope that helps a little. If you need any further clarification, just ask.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.