   Matrix math
  Are these two functions equivalent?Also, is it safe to drop the 4th component of the resulting matrix like the author did? I assume it is, when the result has a 1 in the 4th component, but will it? The only way I see it having a 1 is if the 4th column of the rotation matrix is 0,0,0,1. However I do not know if the rotation matrix always will?Original:void FlightCamera::TransformAxis(D3DXVECTOR3 & axis){   // Build a matrix from the camera's orientation   D3DXMATRIXmatRotation;   D3DXMatrixRotationQuaternion(&matRotation, &m_orientation);    // Transform the queried axis vector by the matrix.   D3DVECTORnewAxis;   newAxis.x = axis.x * matRotation._11 + axis.y * matRotation._21 + axis.z * matRotation._31 + matRotation._41;    newAxis.y = axis.x * matRotation._12 + axis.y * matRotation._22 + axis.z * matRotation._32 + matRotation._42;   newAxis.z = axis.x * matRotation._13 + axis.y * matRotation._23 + axis.z * matRotation._33 + matRotation._43;   axis = newAxis;}Mine:D3DXVECTOR3 ITransformable::WorldToObjectAxis(const D3DXVECTOR3 & worldAxis){   // Build a matrix from the 3D object's orientation   D3DXMATRIXmatRotation;   D3DXMatrixRotationQuaternion(&matRotation, &m_orientation);    // Transform the axis vector by the matrix.   D3DXVECTOR4objectAxis;   D3DXVec3Transform(&objectAxis, &worldAxis, &matRotation);   return D3DXVECTOR3(objectAxis.x, objectAxis.y, objectAxis.z);}
  Besides that the "original" overwrites the input vector while "yours" does not (but that is obvious), AFAIK the both ways are equivalent (but I'm not a D3D programmer, so you may verify this elsewhere). The "original" handles the input vector "axis" to be a position vector (see the addition of matRotation._4*), and so does D3DXVec3Transform(...) (see documentation).However, IMHO the usage and the nomenclature is not consistent. If you pick an object/camera orientation you normally get a part of the local-to-global) transformation. But the naming of the function WorldToObjectAxis(..) and its parameter worldAxis as well as its result objectAxis let me think that the transform should be applied as a global-to-local transformation.   ;  After smoking a cigarette or two I think I understand. if I put in 0,1,0 that vector is the object's y axis and I am transforming it into the world. Thanks!   ;  If you want the result of the transformation to be a 3-dimensional vector, you can use D3DXVec3TransformCoord.  You can also use D3DXVec3TransformNormal, which will only apply the rotation portion of a matrix to a vector (it doesn't matter in this case, since your matrix only has rotation anyway).   