# Quaternion\Coord system

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

## Recommended Posts

Hello, Let be a quaternion Q1 and a vector U1 that represent a coordinate system (unit quaternion + vector = matrix = coordinate system). Let be a quaternion Q2 and a vector U2. How can I calculate the quaternion Q2' the Q2 quaternion in the ( Q1, U1 ) coordinate system ? Q2' = Q1*Q2*1/Q1 ? Q2' = Q1*Q2*Q1_ (Q1_ conjugate of Q1) ? And what about the vector U2' ? U2' = Q1.matrix*U2 + U1 ? U2' = Q1*U*Q1_ + U1 ? That I want exactly is the rotation quaternion in a coordinate system given by Q1 and U. Can you please help me on this subject ? Thank You.

##### Share on other sites
hmm, this is very interesting... You mean, the unit quaternion Q1 implies an orientation (version of the system's axes) plus the vector U1 to translate the origin to a new point... This sounds like a typical linear trasformation but expressed as a pair of a quaternion and a vector... Intriguing!

I believe that U1 shouldn't affect the transformation of any quaternion -or vector- to the new system of coordinates. For vectors, this is obvious since vectors are not affected by translation, if they are moved so to remain parallel to their original orientation. (unless of course, you want to treat vectors as points rather as abstact directions of given magnitude)
Also, any quaternion is merely the quotient of two vectors, therefore it should remain unaffected by U1 too, when projected to the new system.

I will have to give this a little more thought though, before I can suggest any formula

##### Share on other sites
This sort of thing can be a bit easier with 4x4 matrices, but try this:
Q2' = Q1.Conjugate()*Q2U2' = Q1.Conjugate().Rotate(U2-U1)
Where the Rotate() function applies the quaternion rotation formula q*p*conjugate(q). Anyway, not positive I got the order right, but that's the general idea.

##### Share on other sites
Quote:
 Original post by someusernamehmm, this is very interesting... You mean, the unit quaternion Q1 implies an orientation (version of the system's axes) plus the vector U1 to translate the origin to a new point... This sounds like a typical linear trasformation but expressed as a pair of a quaternion and a vector... Intriguing!

:D

Quote:
 Original post by someusernameI believe that U1 shouldn't affect the transformation of any quaternion -or vector- to the new system of coordinates. For vectors, this is obvious since vectors are not affected by translation, if they are moved so to remain parallel to their original orientation. (unless of course, you want to treat vectors as points rather as abstact directions of given magnitude)Also, any quaternion is merely the quotient of two vectors, therefore it should remain unaffected by U1 too, when projected to the new system.I will have to give this a little more thought though, before I can suggest any formula

Oh, U represents a point yes, the coordinate system center.

##### Share on other sites
Quote:
 Original post by jykThis sort of thing can be a bit easier with 4x4 matrices, but try this:Q2' = Q1.Conjugate()*Q2U2' = Q1.Conjugate().Rotate(U2-U1)Where the Rotate() function applies the quaternion rotation formula q*p*conjugate(q). Anyway, not positive I got the order right, but that's the general idea.

Q1.Conjugate().Rotate(U2) + U1 I think for what I want. Q2 and U2 represent a transformation I want in the coordinate system (U1, Q1).

##### Share on other sites
The quaternion could be converted to a rotation matrix, itself interpretable as a basis. The vector could be interpreted as a point and used as the origin. So a frame
F(Q,U)
could be defined from the both.

If done so, you have two frames
F1 := F(Q1,U1) and F2 := F(Q2,U2)
both given in the global frame, I assume.

To transform from global to local frame the inverse transform has to be applied. In matrix (column order) form, that would be like
( T1 * R1 )-1 = R1-1 * T1-1

Re-interpreting it with quaternions, it means that
Q2' := Q1-1 * Q2
(since orientations are invariant to translations), and
U2' := Q1-1 * ( U2 - U1 ) * Q1
where -U1 expresses the negative T1, and the product of quaternion and vector expresses the quaternion rotation applied to a vector.

EDIT: Hmm, from the matrix order I would assume the form of jyk is right, since T1-1 is to be applied before R1-1 (see my interpretation above). But I'm not sure at all.

[EDIT: There was a U2 vs U1 exchange.]
[EDIT: And moreover a *Q1 was missed.]

[Edited by - haegarr on January 30, 2006 8:54:00 AM]

##### Share on other sites
Thank you for this formula, I haven't it at all.

But a thing is not clear in my explanation.

F = (Q2, U2) represent a transformation. I need the transformation F', a global space transformation, that is the transformation F in the coordinate system (Q1, U1).

(here U1 is a point, U2 a vector.. sorry that was not clear)

With matrix, i use generaly : R2' = R1*R2*R1^(-1) where R1 is the coordinate system matrix, R2 the rotation matrix wich is expressed in the global space but in fact is a R1 space rotation and R2' the result (the rotation matrix R2 of the R1 space expressed in the global space).

Is that clear ? :D

##### Share on other sites
Quote:
 Original post by WoodchuckThank you for this formula, I haven't it at all.But a thing is not clear in my explanation.F = (Q2, U2) represent a transformation. I need the transformation F', a global space transformation, that is the transformation F in the coordinate system (Q1, U1).
If you mean you want F(Q2,U2) as expressed in the local space of F(Q1,U1), where both F()'s are given in world space, then that's the equation that haegarr and I were trying to give (I think)...
Quote:
 (here U1 is a point, U2 a vector.. sorry that was not clear)
Now I'm confused - maybe we're talking about different things. Why is U1 a point and U2 a vector?
Quote:
 With matrix, i use generaly : R2' = R1*R2*R1^(-1) where R1 is the coordinate system matrix, R2 the rotation matrix wich is expressed in the global space but in fact is a R1 space rotation and R2' the result (the rotation matrix R2 of the R1 space expressed in the global space). Is that clear ? :D
Hehe, 'fraid not :) Are those 4x4 matrices, or 3x3? When you say 'coordinate system matrix', do you mean a full affine transform? If so, perhaps some different variable names would help.

Better yet, maybe you could describe the context, or what it is you're trying to do. That might clear things up.

##### Share on other sites
So (Q2,U2) is a local transformation given in the frame (Q1,U1), and you want the transformation being transformed into the parent frame of (Q1,U1)? So you mean a "simple" transformation concatenation?

In hom. matrix (column vector) form I expect this being
T1 * R1 * T2 * R2 * X
or in affine matrix form
T1 + R1 * ( T2 + R2 * X ) == T1 + R1 * T2 + R1 * R2 * X
where X is a variable vector to allow the following step.

Comparing the coefficients with the normal form yields in
T' := T1 + R1 * T2
R' := R1 * R2
doesn't it?

Confusion everywhere ;)

EDIT:
Quote:
 Original post by jykNow I'm confused - maybe we're talking about different things. Why is U1 a point and U2 a vector?

I assume it is because U1 denotes the origin of a co-ordinate frame, and U2 denotes a translation vector. Similarly, Q1 denotes an orientation, and Q2 denotes a rotation. Say, (Q1,U1) is a frame and (Q2,U2) a transformation. Just a question of convention...

##### Share on other sites
I think the quaternion for the base is Q2*Q1T, since the axes of (Q1,U1) must be first mapped to the world axes and then onto those implied by Q2.

Any vector U in (Q1,U1) space must be mapped to:
U' = Q2*Q1T*(U-U1) + U2

I can't guarantee this being correct, though. Let me know if you try it anyway.

edit:
use U' = Q2*Q1T*U + (U2-U1) instead. It doesn't make sense subtracting vectors expressed in different frames of reference

[Edited by - someusername on January 29, 2006 9:38:16 AM]

1. 1
2. 2
frob
16
3. 3
4. 4
5. 5

• 13
• 13
• 60
• 14
• 15
• ### Forum Statistics

• Total Topics
632124
• Total Posts
3004248

×