Homework V
Perspective Viewing Implementation
1.0 Abstract
We use a 3D basis-to-basis transformation and a 3D-to-2D projection(*) to implement the perspective viewing.
2.0 Idea of the codes
perspective viewing
There are three steps when we do the perspective viewing: First, we do the basis-to-basis transformation to transform object in global basis to in local basis (basis in view point). Secondly, we project those points from 3D to 2D by equations
X = - focus length * x / z (!)(!!)
Y = - focus length * y / z
(!) capital letter means the coordinate is on 2D, lower letter means it's in 3D
(!!) minor sign is needed for right hand axles system
Finally, we do the simple linear transformation in 2D, from Euclid plane to window screen.
User Interface
We can change the view point by mouse dragging, the point is that how you can explain where the view point should go by a 2D mouse dragging. We use two points (one for two free moving degrees) to implement it. One is the view point, another is the shadow of view point on z = 0 plane. When you drag the view point, we don't change the local z coordinate of view point, that means view point only can travel on the local z = 0 plane. To change the local z coordinate of view point, you can drag the shadow of it on global z = 0 plane. If the local z = 0 plane and the (global) z = 0 plane are not parallel, these things always can be done (four free degrees to change the coordinate of view point).
(*) see Chapter 6 in 'Computer Graphics, Principles and Practice' by Foley, van Dam, Feiner a
nd Hughes, 2nd Edition, Addison Wesley, 1990