   Rotation matrix
  This has been bugging me for days now.  All I need is a matrix which rotates a unit vector V = [Vx Vy Vz] to align with the Z-axis.Please help!  I swear I''ve been trying to get this for days, whenever I try to derive it myself I keep getting a matrix which works for some V''s, but not others.  I just need the matrix so I can see what I''ve been doing wrong.Thanks,Dave. 
  ok, first you can get the axis of rotation using the cross product:axis of rotation = V X Zaxisand you can get the angle between the vectors using the dot product:cos(angle) = (V dot Z) / |V|*|Z|as for making the matrix, there was a site that explained this process (it seems to be down ATM)http://www.makegames.com/3drotationsearch the GD forums for posts by diane gruber (dgruber) i think she wrote the article ;  I know the general idea is to rotate into a plane and then perform a second rotation in that plane to align with the axis, but whenever I try and calculate the composite matrix it gives erroneous results when I test it.  I just need a matrix that I can use to verify my results and see where I went wrong.  Can anybody just post a matrix that I can use to see what I''m doing wrong? ;  here's how to generate the matrix once you use my methods above to get the axis and angle:// assume: (x y z) are the components of the rotation axisfloat c = cos(angle);float s = sin(angle);float t = (1 - c); | (t*x*x + c)   (t*x*y - s*z) (t*z*x + s*y) |Matrix M = | (t*x*y + s*z) (t*y*y + c)   (t*z*y - s*x) | | (t*x*z - s*y) (t*z*y + s*x) (t*z*z + c)   |  [edited by - mightyjebus on May 12, 2004 2:21:55 PM];  A couple of other things:Don''t forget to normalize your rotation axis (x,y,z) -- otherwise you''ll get odd results.  And that matrix will only work with column vectors.  If you''re using row vectors (i.e. your multiplication order is vector*matrix) you''ll need to transpose it.;  Part of the problem is that there are an infinite number of solutions. You want to limit it to only one of them. To do that you have to pick a vector that is perpendicular to the vector you are aligning and then align that vector with the X or Y axis. 