CATransform3DMakeRotation的x,y,z参数
The following example creates a transformation for the purpose of rotating a layer:
CATransform3D myTransform; myTransform = CATransform3DMakeRotation(angle, x, y, z);
The CATransform3DMakeRotation function creates a transformation that will rotate a layer by angle radians using an axis of x-y-z. The values for x-y-z define the axis and magnitude for each space (between −1 and +1). Assigning a value to an axis instructs the transformation to rotate using that axis. For example, if the x-axis is set to either −1 or +1, the object will be rotated on the x-axis in that direction, meaning it will be rotated vertically. Think of these values as inserting straws through the image for each axis. If a straw were inserted across the x-axis, the image would spin around the straw vertically. You can create more complex rotations using axis angle values. For most uses, however, values of −1 and +1 are sufficient.
To rotate a layer by 45 degrees on its horizontal axis (rotating vertically), you might use the following:
myTransform = CATransform3DMakeRotation(0.78, 1.0, 0.0, 0.0);
To rotate the same amount horizontally, specify a value for the y-axis instead:
myTransform = CATransform3DMakeRotation(0.78, 0.0, 1.0, 0.0);
The value 0.78, used in the previous example, is calculated as the radian value of the angle. To calculate radians from degrees, use the simple formula Mπ/180. For example,45π/180 = 45(3.1415) / 180 = 0.7853.