Graphics Programs Reference
In-Depth Information
63
64
65
66
67
68
thisObj._xscale = thisObj._yscale = 100*pRatio;
// adjustment for upper-left registration point
thisObj._x -= thisObj._width/2;
thisObj._y -= thisObj._height/2;
Viewer Rotation
We have seen that rotating an object about one of the three coordinate axes is a fairly
straightforward process. Rotating a viewer around one of the axes is a bit more com-
plicated. Let's look at the case where the viewer rotates around the y-axis as shown in
the left side of Figure 7.20.
As the viewer rotates, the relative coordinates of each object need to be updated. Any
point (x,y,z) in 3D space yields a corresponding point (x,z) when projected onto the x-
z plane. This point is at some angle A to the x-z plane. When the viewer rotates about
the y-axis, that point has new coordinate values (x',z'). What we need to know is, what
are the values of (x',z') when the viewer rotates through some angle B? Note that since
the rotation is in the x-z plane, the vertical or y-values are unaffected.
Y (axis of rotation)
Z
(x,y,z)
(x',z')
rotation = B
(x,z)
angle = A
viewer
Z
X
X
Figure 7.20 Rotation of a viewer about the y-axis
To get the coordinates of the new point expressed in terms of the original point, we
need to know how to calculate sin(A+B) and cos(A+B). Let's omit all the gory details
 
Search WWH ::




Custom Search