크기 조정 및 회전 인 경우 옵션은 실제로 (i) 배율을 결정하고 해당 배율의 새로운 배율 매트릭스를 만듭니다. 또는 (ii) 제안대로 회전을 결정하고 반대의 양만큼 변형을 조정하십시오.
변환 행렬의 구성 요소를 보면 두 가지 중 하나를 얻을 수 있습니다. 행렬 곱셈이 어떻게 작동하는지 생각해 보면 출력 x 축은 (transform.a, transform.b)
이고 출력 y 축은 (transform.c, transform.d)
입니다.
그래서, 대한 (I), (II)에 대한
// use the Pythagorean theorem to get the length of either axis;
// that's the scale, e.g.
CGFloat scale = sqrtf(
self.transform.a*self.transform.a +
self.transform.b*self.transform.b);
self.transform = CGAffineTransformMakeScale(scale, scale);
:
// use arctan to get the rotation of the x axis
CGFloat angle = atan2f(
self.transform.b*self.transform.b, self.transform.b*self.transform.a);
self.transform = CGAffineTransformRotate(self.transform, -angle);
다른 종류의 변환을 수행합니까? 스케일링, 회전 및 변환 또는 이와 유사한 하위 집합일까요? – Tommy
크기 조정 및 회전 @ 토미 –