This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Negative Quaternion coefficients?

Tags: None
(comma "," separated)
twood
Registered Member
Posts
17
Karma
0

Negative Quaternion coefficients?

Tue Sep 18, 2012 4:24 pm
Hi,
I have some code that constructs a transformation matrix like so:
Code: Select all
double a = sqrt(1 - (b*b + c*c + d*d));
Quaterniond Q1(a, b, c, d);
Affine3d S; S = Scaling<double>(u, v, w);
Affine3d T; T = Translation3d(x, y, z);
Affine3d Transformation = T*S*Q1;

Where b, c, d, u, v, w, x, y, z are all sensible doubles read in from a data file. If I then try to recalculate the Quaternion coefficients like so:
Code: Select all
Affine3d R; R = Transformation.rotation();
Quaterniond Q2(R);

and then compare the coefficents (.vec()) of Q1 and Q2 they are precisely the negative of each other. However, Quaternions with opposite coefficients are not equivalent. Am I missing something about Quaternion maths, or is this a bug?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
q and -q do represent the same rotation.
twood
Registered Member
Posts
17
Karma
0

Re: Negative Quaternion coefficients?

Thu Sep 20, 2012 10:01 am
Yes, you are right. Thank you.

I was dealing with a data format that only stores the x, y, z Quaternion coefficients, and then requires w >= 0 to save space. If you reverse x, y, z, but not w you do get a different rotation, which is what I was seeing. All fixed now and definitely a bug in my thinking, not in Eigen.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]