I have written two different ways to transform Euler Angles to the normalized unit direction vector. But i'm not sure which one is the faster. The one which uses trigonometry operations or the one that transforms the forward vector through matrix?
D3DXVECTOR3 EulerToDir(D3DXVECTOR3 EulerRotation) { return D3DXVECTOR3(sin(EulerRotation.x)*cos(EulerRotation.y), -sin(EulerRotation.y), cos(EulerRotation.x)*cos(EulerRotation.y)); }//Convert euler angles to the unit direction vector.
D3DXVECTOR3 EulerToDirM(D3DXVECTOR3 EulerRotation)//Same thing but using matrix transformation. More accurate.
{
D3DXMATRIX rotMat;
D3DXMatrixRotationYawPitchRoll(&rotMat, EulerRotation.x, EulerRotation.y, EulerRotation.z);
D3DXVECTOR3 resultVec(0, 0, 1);//Facing towards the z.
D3DXVec3TransformNormal(&resultVec, &resultVec, &rotMat);
return resultVec;
}
Thanks.