How is CATransform3DMakeRotation used?
Solution 1
The first is the angle in radians the other 3 parameters are the axis (x, y, z). So for example if you want to rotate 180 degrees around the z axis just call the function like this:
myView.layer.transform = CATransform3DMakeRotation(M_PI, 0.0, 0.0, 1.0);
and apply the result to the transform property of the view you want to rotate.
Solution 2
You'll probably find these useful when using radians:
CGFloat DegreesToRadians(CGFloat degrees)
{
return degrees * M_PI / 180;
};
CGFloat RadiansToDegrees(CGFloat radians)
{
return radians * 180 / M_PI;
};
Solution 3
They represent the axis about which you want to rotate. Use 0,0,1 to rotate in the plane of the screen.
Related videos on Youtube
![Daniel says Reinstate Monica](https://i.stack.imgur.com/XmzQi.png?s=256&g=1)
Daniel says Reinstate Monica
Former moderator on Blender SE. The recent actions of Stack Exchange have been reprehensible. The lack of professional conduct, the tone deaf way they've been dealing with the community, and the unfair and unjustified way they've dealt with Monica Cellio. Monica is an exemplar of the community, it's incredible how she's managed to keep a level head during this time when emotions have been very high. REINSTATE MONICA
Updated on November 11, 2020Comments
-
Daniel says Reinstate Monica over 3 years
I can not figure out how to use
CATransform3DMakeRotation()
. Can somebody please tell me how to use it?I think the first parameter is the angle, right? But what are the other three?
-
Brad Larson over 13 yearsSee also the Core Animation Function Reference for the definition of the function: developer.apple.com/documentation/quartzcore/…
-
Daniel says Reinstate Monica over 13 yearsso basically i just set the angle and put 1.0 on the x, y, or, z that i want to use? is it always 1.0?
-
Brad Larson over 13 years@Dan - No, it's not always 1.0 for the axes. The X, Y, and Z components define an axis about which rotation takes place. Setting 1.0 for a component, and leaving the other to at 0.0, defines a rotation about the X, Y, or Z axis, but you can rotate about any arbitrary direction. This lets you manipulate views and layers in a truly 3-D manner.