开发者

Rotation around Z from a non-skew, affine orthogonal projection matrix

开发者 https://www.devze.com 2023-03-03 00:40 出处:网络
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 or

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 ) );
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号