Using quaternions to perform rotations

AI Thread Summary
The discussion centers on the use of two quaternion equations for performing rotations: v' = q^{-1}vq and v' = qvq^{-1}. While both equations can represent the same rotation, the difference lies in their conventions and the order of quaternion multiplication, which is non-commutative. The first equation is interpreted as rotating the frame around a vector, while the second rotates the vector within the frame. Understanding these conventions is crucial for accurate quaternion application, especially when exchanging data between different systems. Ultimately, the choice of convention affects how rotations are computed and understood.
ryan88
Messages
41
Reaction score
0
Hi,

I have been looking at quaternions to perform rotations, however I have come across two slightly different equations to do this:

v' = q^{-1}vq
v' = qvq^{-1}

What is the difference between these two?

Thanks,

Ryan
 
Physics news on Phys.org
There is no difference. They just have the q's in a different order.

EDIT: Actually, nevermind that. Quaternion multiplication doesn't commute.
 
The difference ought to be just a matter of definition. The q in the first line is going to be the same as the q^{-1} in the second to describe the same rotation.
 
If I have a vector like so:

v=\begin{bmatrix}<br /> 0\\<br /> 1\\ <br /> 0\\ <br /> 0<br /> \end{bmatrix}

and the following quaternion which should perform a 90° rotation about the z axis:

v=\begin{bmatrix}<br /> 0.7071\\<br /> 0\\ <br /> 0\\ <br /> 0.7071<br /> \end{bmatrix}

I would expect to obtain the following vector:

v=\begin{bmatrix}<br /> 0\\<br /> 0\\ <br /> 1\\ <br /> 0<br /> \end{bmatrix}

If I use the first of the two equations in my first post, this gives the following vector:
v=\begin{bmatrix}<br /> 0\\<br /> 0\\ <br /> -1\\ <br /> 0<br /> \end{bmatrix}

whilst the second equation gives me the answer I expect.

Does this mean that the first of the two equations is rotating the frame around the vector, whilst the second is rotating the vector within the frame?

Thanks,

Ryan
 
Where exactly have you seen the first one? I'm only familiar with the second.
 
As I said, it's a convention. You can't expect to plug in some specific quaternion for q and get the result you "expect" without knowing which convention the q came from.
 
Isn't it just the opposite rotation of the other equation? Since q and q^-1 are inverses, using equation one is the equivalent to using equation two with the inverse of q.
 
As further clarification of my earlier post, please consider the following diagram:
http://img171.imageshack.us/img171/2594/vec1a.png

This shows the following vector:
v=\begin{bmatrix}0\\1\\0\\0\end{bmatrix}

If I want to perform a right handed rotation of 90° around the z axis of the above axes, this quaternion can be computed as follows:
q_0 = \cos\left(\frac{\theta}{2}\right )
q_1 = 0\times\sin\left(\frac{\theta}{2}\right )
q_2 = 0\times\sin\left(\frac{\theta}{2}\right )
q_3 = 1\times\sin\left(\frac{\theta}{2}\right )

Giving the following:
q=\begin{bmatrix}0.7071\\0\\0\\0.7071\end{bmatrix}

Performing this rotation graphically would give:
http://img443.imageshack.us/img443/9341/vec2.png

Giving the following vector:
v&#039;=\begin{bmatrix}0\\0\\1\\0\end{bmatrix}

If I use the following quaternion vector rotation equation, I get the answer I expect:
v&#039;=qvq^{-1}

However, using the following equation:
v&#039;=q^{-1}vq

gives me the following vector:
v&#039;=\begin{bmatrix}0\\0\\-1\\0\end{bmatrix}

showing this graphically, it seems that it has done the following:
http://img256.imageshack.us/img256/6962/vec3.png

either that or it has performed a -90° rotation around the z axis.

I would just like to know if one does represent rotating a vector within a frame and the other rotating the frame around a vector, or is it simply that if q=q^{-1} then (q^{-1})^{-1}=q?

Thanks,

Ryan
 
Last edited by a moderator:
  • #10
There are a couple viewpoints on this. Yes, you can say that one convention represents an active transformation and the other a passive one. But, you can also say that they both represent active transformations, and each just demands a different method of calculating q.

In other words, let q = p^{-1}. Your first equation is

v&#039; = p v p^{-1}

Your second equation could then be written as

v&#039; = q v q^{-1}

They both have the same form. Shifting the inverse around doesn't really do anything. It's just that you're insisting on plugging in the quaternion you think is right as p^{-1} in the first equation when you should be plugging it in as p. The problem here isn't with the equations. It's how you're arriving at "this is the quaternion I think is q" in the first place.
 
  • #11
Murphrid, don't the two expressions amount to doing the opposite rotation?

Since the first equation is just the second equation with the inverse of q, and since q^{-1}q = 1, applying both to the same vector should bring it back to the original state. In geometric terms, this is the equivalent of doing two opposite rotations.
 
Last edited:
  • #12
Yes, they do, I'm not disputing that. I'm just trying to show that the descriptions both have the same form, and any difference between the two is a matter of convention.

Mostly I'm trying to question why ryan88 expects the given quaternion to produce a given rotation. Why not expect the inverse of that quaternion to do it instead? It's all just a matter of convention.
 
  • #13
ryan88 said:
I have been looking at quaternions to perform rotations, however I have come across two slightly different equations to do this:

v&#039; = q^{-1}vq
v&#039; = qvq^{-1}

What is the difference between these two?
Semantics, nothing else.

A very similar issue arises with similarity transformations. Should they be written as PAP^{-1} (e.g. http://mathworld.wolfram.com/SimilarityTransformation.html) or P^{-1}AP (e.g., http://en.wikipedia.org/wiki/Similar_matrix)? The answer is "yes". The same applies to quaternions when used to represent rotations.

In other words, there is no right way / wrong way. What is wrong is arguing that one way is right, the other wrong. One way is right, but the other way isn't wrong. It's left. I (and others) call the quaternion q in the form v&#039;=qvq^{-1} a "left" quaternion while the form v&#039;=q^{-1}vq uses a "right" quaternion. Is the original quaternion is on the left or the right?

There are subtle differences in the representation. The equation that relates the time derivative of the quaternion to angular velocity takes on a slightly different form for left and right quaternions, and how quaternions for multiple reference frames chain also differs.

With regard to the latter, suppose you have three frames of interest denoted A, B, and C. Suppose you also know the quaternion q_{A\to B} that transform a vector from frame A to frame B, and you know the quaternion q_{B\to C} that transform a vector from frame B to frame C. Finally, suppose that you do not know, but need to know, the quaternion q_{A\to C} that transforms a vector from frame A to frame C. It's an easy computation. With left quaternions, q_{A\to C} = q_{B\to C}q_{A\to B}. Left quaternions chain from right to left. This is exactly how transformation matrices chain. With right quaternions, q_{A\to C} = q_{A\to B}q_{B\to C}. This is analogous to how vectors chain, end to end.

One last issue occurs when two organizations that uses quaternions need to exchange data. Someone had better beware of this left versus right ambiguity. Tempers will flare otherwise! I've seen this silliness firsthand.
 
  • #14
Ok, so how do I know whether a quaternion I define is a right of left quaternion?

For example, as I said in an earlier post:

ryan88 said:
If I want to perform a right handed rotation of 90° around the z axis of the above axes, this quaternion can be computed as follows:
q_0 = \cos\left(\frac{\theta}{2}\right )
q_1 = 0\times\sin\left(\frac{\theta}{2}\right )
q_2 = 0\times\sin\left(\frac{\theta}{2}\right )
q_3 = 1\times\sin\left(\frac{\theta}{2}\right )

Giving the following:
q=\begin{bmatrix}0.7071\\0\\0\\0.7071\end{bmatrix}

Is this an example of a right or left quaternion?

Thanks,

Ryan
 
  • #15
ryan88 said:
Ok, so how do I know whether a quaternion I define is a right of left quaternion?
If you defined it, you should know. On the other hand, if all you have are the four elements of a quaternion as numbers from some other organization, you had better well ask. You had also better ask a couple of other questions:
  • Which of those four numbers is the scalar (real) part of the quaternion?
    Some people place the real part of the quaternion as the first of the four values. For others, it is the last of the four values. There's no right way / wrong way, so you need to ask.
  • Is this a rotation quaternion or a transformation quaternion?
    Or as some put it, active versus passive transformation (http://en.wikipedia.org/wiki/Active_and_passive_transformation). Does the quaternion represent the physical rotation of some object (e.g., moving the hour hand of a clock from 2 to 3 to mark the onset of daylight savings time, or physically rotating a robotic arm by some amount), or does it represent the transformation of the representation of a vector from one reference frame to another?
Is this an example of a right or left quaternion?
From the way you wrote that, that appears to be either a left rotation quaternion or a right transformation quaternion. They have exactly the same form.Muphrid was spot on when he said "It's all just a matter of convention." There are eight possible conventions here, (left vs right) × (rotation vs transformation) × (scalar first vs last). If you are defining the system, you get to choose the convention. If you are exchanging quaternions with some other organization, you had better well ascertain the conventions used by that other organization. The same applies when you are reading some poorly written journal paper that describes a nifty rotational control system: You need to ferret out the convention used by that author.
 
Back
Top