Rotation around Z from a non-skew, affine orthogonal projection matrix
I can't seem to find an answer to what I thought should be a fairly straightforward problem.
I'm trying to get the z-rotation of a matrix which represents the scale, transform and rotation of an orthogonal projection which always looks towards Z. Just the rotation around Z.
I realise that there may not be a solution that covers 100% of uses (non-affin开发者_如何转开发e, skew, etc), but I just need one for this case.
Purpose is to get something else working (just need to fudge this part together for now) in a simple CAD viewer.
Well the first and second rows of the matrix are the side and up vectors (respectively)
So assuming that the up vector would point straight up (for no z-rotation) and the side vector would point to the right you can work out what the angle is between the expected (ie non rolled) vector and the vector you have. This is simply the result of calling
float angle = acosf( DotProduct( identityUp, actualUp ) );
精彩评论