Anyone got a snippet to multiply two Quaternions?
Posted on 2004-07-01 00:17:45 by Homer
hello EvilHomer2k

I haven't translated it to asm yet but, this is the formula:

//-----------------------------------------------------------------------------
// Name: D3DMath_QuaternionMultiply()
// Desc: Mulitples two quaternions together as in {Q} = {A} * {B}.
//-----------------------------------------------------------------------------
VOID D3DMath_QuaternionMultiply( FLOAT& Qx, FLOAT& Qy, FLOAT& Qz, FLOAT& Qw,
FLOAT Ax, FLOAT Ay, FLOAT Az, FLOAT Aw,
FLOAT Bx, FLOAT By, FLOAT Bz, FLOAT Bw )
{
FLOAT Dx = Ax*Bw + Ay*Bz - Az*By + Aw*Bx;
FLOAT Dy = - Ax*Bz + Ay*Bw + Az*Bx + Aw*By;
FLOAT Dz = Ax*By - Ay*Bx + Az*Bw + Aw*Bz;
FLOAT Dw = - Ax*Bx - Ay*By - Az*Bz + Aw*Bw;

Qx = Dx; Qy = Dy; Qz = Dz; Qw = Dw;
}
Posted on 2004-07-01 03:54:59 by Siekmanski
Thanks, meanwhile I realized theres a D3DXQuaternionMultiply function, and used that.

On researching the calculation however, I noted there are TWO common methods for solving this problem, yours is the "concatenation" method, there's another.
Posted on 2004-07-01 04:22:22 by Homer

Thanks, meanwhile I realized theres a D3DXQuaternionMultiply function, and used that.

On researching the calculation however, I noted there are TWO common methods for solving this problem, yours is the "concatenation" method, there's another.

What is the second method? Do you have a code snippet for it? I wrote an SSE2 tutorial using the first method. You can read it here. I get the code running in 20 cycles on a P4.

http://www.masmforum.com/viewtopic.php?t=3469
Posted on 2004-07-01 21:41:48 by mark_larson
Posted on 2004-07-01 22:19:39 by Homer