   3D objects and vectors
  I''m doing a bit of programming and learning.  As part of my driving problem, I''ve got the following situation.  I have 2 objects with a radius (might as well consider them spheres), a heading (orientation), etc.  For the purposes of this problem, all I really care about is the angle between the vectors of the 2 objects, however, I want to utilize data structures that will be useful later on.So, I can store the object coordinates in a 3d point, and it''s heading in a 3d unit vector.  I can take the dot product of the vectors of any two objects and calculate the angle between them.However, when looking through code, I notice that most programs I''ve looked at store object information in a 4x4 matrix (view, scale, and translation matrix combined).  This makes other calculations about the object fairly easy to do.So, the question is:  if I store information about an object in a 4x4 matrix for orientation, scaling, etc, how do I calculate the angles between two objects?  Which parts of the matrices do I use for the dot product?  Or is there some other equation that I don''t know about?In case it matters, I''m using D3DXMATRIX structures to store my object orientations. 
  first, 4x4 doesnt automatically contain scaling. the 3x3 part is the rotation (where you can add scaling if you really really have to) and the last vector is your position. the 3x3 part are your right/up/forward vectors. the part you want should be Matrix.m[2]. ;  This is a decent pdf on ''homogeneous coordinates'':<a href="http://www.geometer.org/mathcircles/cghomogen.pdf">Homogeneous Coordinates</a> ;  I realize this is basic linear algebra stuff, but bear with me - I''m playing catch-up.  I never took linear algebra and I''m still trying to grok some of the nuances of matrix math.Alright, so I can get my right, up, and forward vectors out of the matrix.  I''m still fairly confused as to how I translate the right, forward, and up vectors into a single vector that is the overall "facing" of the object.  That vector is what I need to do the dot product, or so I believe.Is there some funky thing I can do directly to the matrices to get the angle?  Or do I need to get the values of the right, up, and forward vectors, do something to them to combine them into one vector, and then take the arccos of the dot product to get the angle between the two objects (assuming these are unit vectors)?