Jump to content
  • Advertisement
Sign in to follow this  
hbdevelop1

Quaternions concatenation is the sum of angles ?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

With the two quaterions q1=q2=(pi/8, 1, 0, 0)
Does the product q1q2 yield a third quaternion q3 equal (pi/4, 1, 0, 0) ?

This is the result I am expecting to have from my quaternion class, but I don't have it.
My expectation is based on the fact that the concatenation of q1 and q2 will yield a quaternion representing both rotations. That means, for me, the sum of the angles each quaternion represents if the rotations are around the same vector.

So, does the product q1q2 yield a third quaternion q3 equal (pi/4, 1, 0, 0) ?
Or is there anything wrong with my assumption ?

Thank you in advance

Share this post


Link to post
Share on other sites
Advertisement
Quaternion (pi/8, 1, 0, 0) does not represent rotation you wanted.
Quaternion for rotation by an angle theta around an axis A is computed by this formula:
q = (cos theta/2, Ax sin theta/2, Ay sin theta/2, Az sin theta/2) Edited by teccubus

Share this post


Link to post
Share on other sites
Oh! Yes, you are right.
I was thinking of my code while writing the email.
Because my code looks like :

HQuaternion q1(PI_over_8,HVector3(1,0,0));
HQuaternion q2(PI_over_8,HVector3(1,0,0));
HQuaternion r1=q1*q2;
HQuaternion q3(PI_over_4,HVector3(1,0,0));
assert(r1 == q3);

Please respond my second email "Quaternions concatenation is the sum of angles ? (2)"

Thank you

Share this post


Link to post
Share on other sites
I think the problem is with your comparision code.
Quaternions have float components. You CAN'T compare floats directly.
Please read this:
http://floating-point-gui.de/

Share this post


Link to post
Share on other sites
I found out my error when I was trying to write my respond explaining that I am doing nothing wrong !

My product operator expects a quaternion class constructor with the W component as a first parameter.
While the available constructor expects an angle as the first parameter.

HQuaternion HQuaternion::operator*(HQuaternion & q)
{
return HQuaternion(
w*q.w - v.Dot(q.v),HVector3(q.v*w + v*q.w + v.Cross(q.v) )
);
}
HQuaternion::HQuaternion(double angle, HVector3 & _v):v(_v)
{
double angleover2 = angle/2;
double c = cos(angleover2);
double s = sin(angleover2);
v.Normalize();
w=c;
v *= s;
}

Thank you for your responses and for the link

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!