Graphics Reference
In-Depth Information
Figure 5.7 The X, Y, and Z axes, and the planes of rotation around them
As you can see from the figure, a rotation around the Z axis is equivalent to the 2D affine
rotation we made earlier. A rotation around the X or Y axes, however, rotates a layer out of
the 2D plane of the screen and tilts it away from the camera.
Let's try an example: The code in Listing 5.4 uses CATransform3DMakeRotation to
rotate our view's backing layer by 45 degrees around the Y axis. We would expect this to tilt
the view to the right, so that we are looking at it from an angle.
The result is shown in Figure 5.8, but it's not quite what we would have expected.
Listing 5.4 Rotating a Layer Around the Y Axis
@implementation ViewController
- ( void )viewDidLoad
{
[ super viewDidLoad ];
//rotate the layer 45 degrees along the Y axis
CATransform3D transform = CATransform3DMakeRotation ( M_PI_4 , 0 , 1 , 0 );
self . layerView . layer . transform = transform;
}
@end
Search WWH ::




Custom Search