Angle between vectors

Started by
9 comments, last by darkzim 18 years, 10 months ago
All right guys, if finally got it to work. My end result was:

D3DXVECTOR3 A = GetTranslation() - m_targetpos;
D3DXVECTOR3 B = GetForwardVector() - GetTranslation();

D3DXVec3Normalize(&A,&A);
D3DXVec3Normalize(&B,&B);

float dot = D3DXVec3Dot(&A,&B);

float angle = acosf(dot);

D3DXVECTOR3 cross;
D3DXVec3Cross(&cross,&A,&B);
if(cross.y > 0.0f)
SetRotation(0.0f,-angle,0.0f);
else
SetRotation(0.0f,angle,0.0f);

Thanks for all your help.
-Darkzim

---------------------------------darkzim

This topic is closed to new replies.

Advertisement