   Object alignment (aka billboard)
  Hey guys,I’m not sure if this requires a billboard or if I’m overcomplicating it.I have a Matrix as follows:    Right/X axis    UP/Y axis    Forward/Z axisI want to align the UP/Y to 0,1,0 and adjust the Forward/Z to whatever it should be:    Right/X axis = recalculated based on moving the Y axis from what it was to 0,1,0    UP/Y axis = 0, 1, 0    Forward/Z axis = recalculated based on moving the Y axis from what it was to 0,1,0How do I do this?I’m using C# and XNA, so in the MATRIX class, there are methods for    CreateLookAt    CreateBillboard (spherical billboard)CreateConstrainedBillboard (cylindrical billboard)    CreateFromAxisI’m not sure if its any of these or something else I should be doing?If it is one of these, what values plug in where, because I’ve played with a few of them and haven’t gotten it worked out yet.Thanks   
  So you have matrix M = [X Y Z], M is a 3x3 matrix; X,Y,Z are 3x1 unit vectors.You want to find a rotation matrix R such that R*M = [X' y Z'], where X' and Z' are unit vectors and y=[0 1 0]?One way to solve this is to calculate the axis A and angle t so that rotating the direction vector Y by t about the axis A gives y. In that case:A = Y cross y.t = Y dot y.With this information, the matrix R can constructed: rotation about an arbitrary axisPostnote: Might be that you need to flip the sign of t or reverse A=-A.   ;  I went a simpilar route and it seems to work, tell me what you think?// perform initial rotation    newMat = newMat * Matrix.CreateRotationX(rotationY);// Calculate the DOT and Cross relative to 0,1,0  -- left out code for this// See if we over rotated past the horizonif (mydot >= 1 || mycross.X < 0 ) // If we're trying to rotate too high, above the horrizon, level us at the horrizon{  // Reset the matrix from before the move    newMat = _3rdPersonMat;  // Re-rotate, but this time back off the rotation by the overrotation, resulting in a rotation that brings us right to the horizon    newMat = newMat * Matrix.CreateRotationX(rotationY + mycross.X);}