Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is CATransform3DMakeRotation used?

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?

like image 417
Daniel says Reinstate Monica Avatar asked Jan 02 '11 00:01

Daniel says Reinstate Monica


3 Answers

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.

like image 92
Gu1234 Avatar answered Nov 11 '22 12:11

Gu1234


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;
};
like image 43
ScottWasserman Avatar answered Nov 11 '22 12:11

ScottWasserman


They represent the axis about which you want to rotate. Use 0,0,1 to rotate in the plane of the screen.

like image 3
mvds Avatar answered Nov 11 '22 12:11

mvds