Home » Community » Forums » » Quaternion Powers
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 Quaternion Powers
Post Reply 
I was informed about another typo. Credit goes to Navreet Singh gill.

"Rotation Order - The sequence of rotations in the Euler representation is X, then Y, and then Z. In matrix form:

RotX * RotY * RotZ <-- Very Important"

It should be

RotZ * RotY * RotX

to more closely follow OpenGL "default" convention books.

But I suppose you could view it as v * RxRyRz too and everything's cool.

 User Rating: 1017   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

A little more info about multiplying quaternions:

As stated in the article, multiplying two quaternions in different orders will likely produce different results since i * j = k while j * i = -k.

Let's have a set of rotations called quatFirst, quatSecond, quatThird. We want to apply them in that order.

Let quatTotal be the concatenation of all of these. Initially it's set to w = 1 axis = (0, 0, 0), the multiplicative identity

quatTotal *= quatFirst; // simple

If we want to apply the second rotation, we might try this:

quatTotal *= quatSecond // *** wrong ***

This will produce the wrong rotation. quaternion multiplication requires the order to go from right to left, where the right most is the oldest and the left most the youngest.

quatTotal = quatThird * quatSecond * quatFirst; // correct

or

quatTotal = quatSecond * quatTotal;
quatTotal = quatThird * quatTotal;

(Depends on your multiplication function of course as some libs switch the order for you so you can write it left to right, yet produces the same result)

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

In "What is a Quaternion?",
-----
q = w + xi + yj + zk
where w is a real number, and x, y, and z are complex numbers.
-----

It should be
-----
q = w + xi + yj + zk
where w is a real part of q, and x, y, and z are imaginary part of q.
-----

 User Rating: 1015    Report this Post to a Moderator | Link

Still looking to convert from quat to euler?
Check this.

http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/

dont know if it works still working on it


hope i helped



Posted by MHGameWork


 User Rating: 1015    Report this Post to a Moderator | Link

Hi,

I had seen
"scale = sqrt (x2 + y2 + z2)

Another variation I have seen is that the scale = sin(acos(w)). They may be equivalent, though I didn't try to find the mathematical relationship behind them."

We start with : sin(arcos(w))

sin(arcos(w)) = sqrt( sin²(arcos(w)) );
sqrt( 1 - cos²(arcos(w)) );
sqrt( 1 - w² );
if
x²+y²+z²+w² = 1
then
1-w² = x²+y²+z²

So
sin(arcos(w)) = sqrt( x²+y²+z² );

Enventually,
it run only if the quaternion is normalized.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

"So if we are using a unit quaternion to represent the camera orientation, we have to convert the quaternion to a matrix first: Rotate (from Quaternion) * Translate"

No. A better method to rotate a vector is to use V' = q . V . q*, where :
- q is the quaternion
- V is the "quaternized" vector, i.e. (0, x, y, z) wher (x, y, z) are the vector coordinates
- q* is quaternion's conjugate
- we apply twice the quat multiplication
- the result V' is the "quaternized" form of the rotated vector

It is therefore possible to do all computations with pure quaternion operations, without ever appealing to matrices. This leads to much less computations, and, if i'm not wrong, completly avoids any gimbal lock problems.

Sorry in advance if I have misunderstood what you meant.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Quote:
Original post by MathsPoetry
[...], and, if i'm not wrong, completly avoids any gimbal lock problems.

Gimbal lock depends on Euler angles, not matrices or quaternions. It is entirely possible to avoid gimbal lock with matrices by not using Euler angles, and it is entirely possible to get gimbal lock with quaternions if you use Euler angles.


 User Rating: 1827   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

It's also possible to avoid gimbal lock even if you're using Euler angles. Gimbal lock is dependent on what you're trying to make happen, not just what data representation you're using. If you're not doing any IK, you probably have nothing to fear from gimbal lock.

 User Rating: 2053   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I have certain questions
You said the final quaternion is obtained by Qx * Qy * Qz.Did you also mean the same order of multiplication(if referencing local axis) or Qz * Qx * Qy(if referencing absolute global axis)?In your example you do x then y then z.

Also when we do the multiplication for the quat created on key input,we will again need to keep in mind which axis(global or local) we are referring to right?

I am trying to follow your example and I am again getting a gimbal lock despite the fact that I am using quats.I am following y first then x then z.So my quat was constructed like Q = Qz*Qx*Qy.Is it the premultiplication that tells it that I want to rotate around the absolute global axis?

Its hard to compare to your example directly as I am using a left hand coordinate system with a different order of rotation.

P.S:I believe I have goofed up the math somewhere as after a full rotation of 90 degree around the y axis,if I rotate around the x axis I get an axis value for both x and z.It should be only for x.It works fine till I am rotating around only 1 axis so I think the multiplication should be alright.Finding it hard to pin down the error.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: