   Building an alignment matrix
  The alignment matrix aligns the model space Y axis with the specifiedaxis vector (x,y,z) (which need not be normalized). The rotation isperformed about the vector (a ^ b), where a is (0,1,0) and b is (x,y,z).x -->  Specifies the X component of the axis of alignment.y -->  Specifies the Y component of the axis of alignment.z -->  Specifies the Z component of the axis of alignment.I am having some trouble building the rotation matrix that preforms this action, any help would be great, Thanks.   
  Is there any particular reason you're crossing the target vector with the cardinal Y axis to get your axis of rotation? Usually when you want to rotate a vector a (model space Y) onto a vector b (the target vector), the axis of rotation is chosen so as to be parallel to aXb.   ;  Well as i understand it i need to rotate the model space Y axis (0,1,0) onto target vector (x,y,z), so by crossing (0,1,0) with (x,y,z) that should produce the axis of rotation right? I think i got the solution to my problem in the end, but it seems the object i am rotating is off by a few degrees. With (x,y,z) being (1,0,1) i started with crossing (0,1,0) with (1,0,1) and got (1,0,-1) which i believe should be my axis of rotation, and i used the dot product to find the angle between (0,1,0) and (1,0,1) which i got to be 90 degrees. I then normalized the vextor (1,0,-1). That is my logic, it probably does not all make sense, i am still new to this material, in the end i came up with the matrix:((x*x)*(1-c)+c, (y*x)*(1-c)+(z*s), (x*z)*(1-c)-(y*s),0,(x*y)*(1-c)-(z*s),(y*y)*(1-c)+c,(y*z)*(1-c)+(x*s),0,(x*z)*(1-c)+(y*s),(y*z)*(1-c)-(x*s),(z*z)*(1-c)+c,0,0,0,0,1)where c is cos(90) and s is sin(90).I am sure there are flaws in my process / math and if anyone could point them out i would be thankfull.   ;Quote:Original post by UltraseamusWell as i understand it i need to rotate the model space Y axis (0,1,0) onto target vector (x,y,z), so by crossing (0,1,0) with (x,y,z) that should produce the axis of rotation right? I think i got the solution to my problem in the end, but it seems the object i am rotating is off by a few degrees.Seems like you're mixing world and local space here, which won't work. The terminology can be a bit confusing, but what you want is the cross product of the model local up axis as expressed in world space, with the target vector (x,y,z). The up axis you're looking for should be the second row or column of the transformation matrix for the model. (The key idea here is that for the result to make sense, the two vectors in question need to be in the same space, in this case world space.)That could probably be clearer, so let me know if it doesn't make sense.   