문제

I want to rotate a view around the three axis, with 3 different angles : rx, ry, rz.

Here's what I done :

_tx = CATransform3DMakeRotation(rx*M_PI/360, 1, 0, 0);
_ty = CATransform3DMakeRotation(ry*M_PI/360, 0, 1, 0);
_tz = CATransform3DMakeRotation(rz*M_PI/360, 0, 0, 1);
view.layer.transform = CATransform3DConcat(_tx, CATransform3DConcat(_ty, _tz));

I though it was working when I tried to invert the concatenation order. For example,

view.layer.transform = CATransform3DConcat(_tx, CATransform3DConcat(_ty, _tz));

and

view.layer.transform = CATransform3DConcat(_tz, CATransform3DConcat(_tx, _ty));

Do not give the same result !!

  1. Is there a way to rotate around the 3 axis with one CATransform3DMakeRotation?
  2. Or a better way to do this?
도움이 되었습니까?

해결책

Matrix operations are not commutative, changing the order in which you multiply them together will give you different resulting transform matrices.

In which order do you want to apply your 3 different rotations? That is the order that you should concatenate your transform matrices.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top