Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Mar 2012
Offline Last Active Apr 22 2012 08:07 AM

Posts I've Made

In Topic: Quaternions

30 March 2012 - 12:53 PM

Ok then i got this sorted, ty very much for your help.

In Topic: Quaternions

30 March 2012 - 11:49 AM

This is making me confused, i tought and it made sense. I was happy i got this out of the way, but now i found this here: http://content.gpwiki.org/index.php/OpenGL:Tutorials:Using_Quaternions_to_represent_rotation#Rotating_vectors

They actually normalize the vector they are about to rotate:

// Multiplying a quaternion q with a vector v applies the q-rotation to v
Vector3 Quaternion::operator* (const Vector3 &vec) const
Vector3 vn(vec);

Quaternion vecQuat, resQuat;
vecQuat.x = vn.x;
vecQuat.y = vn.y;
vecQuat.z = vn.z;
vecQuat.w = 0.0f;

resQuat = vecQuat * getConjugate();
resQuat = *this * resQuat;

return (Vector3(resQuat.x, resQuat.y, resQuat.z));

In Topic: Quaternions

30 March 2012 - 10:52 AM

I see, that was very helpful indeed thank you.

What about the vector i want to rotate? on v' = q . v . conj(q), does 'v' also need to be normalized? Because if it does, wont it alter the result intended?

Very sorry if this sound like dumb questions, just started looking at quaternions a few days ago =( You're help is much appreciated.

In Topic: Quaternions

29 March 2012 - 07:20 PM

Its solved, the math i had on paper was right but not the one on code =( both problems were solved, my vector dot product and vector cross product had mistakes. Thank you.

PS: If the vector i want to rotate does not have lenght 1, i need to normalize it? Rotation quaternions, if calculated by that formula are always unit quaternions?

In Topic: Quaternions

29 March 2012 - 02:20 PM

I started to prove that today on paper(yeah by scalar i meant real part, on book im reading he calls it scalar, on some toturials it's the 'w') and thats what i got, it should be zero i was just afraid i did the math wrong. The examples i try on my code dont end up getting 0 on the real part, means im doing something wrong... need to find out what and correct it, just wanted to be sure i was on the right path.

Btw, you say for quaternions that represent rotations |q| = 1, i calculated it, for example with this:
alpha = 90º
v = (1.0,0.0,0.0)
q = [cos(90/2), sin(90/2) * (v)]
But it did not result in a normalized quaternion, again the math on my code must be working improperly right?

Thank you.

PS(before calculating the cos or sin, i convert de degree's to radians)