Anyone got a snippet to multiply two Quaternions?

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;

}

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;

}

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.

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

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