## Rendering Three-Dimensional Objects

The Aspect menu allows the user to modify the various aspect parameters, which determine how a three-dimensional object will be rendered on the screen. They are:

A vector, ViewPoint.
The point from which we are observing a 3-dimensional mathematical scene.
A unit vector, ViewDirection.
The direction in which we are looking. It is also the normal vector to a plane called ImagePlane, which plays a role analagous to that of the eye's retina.
A positive real number, FocalLength.
The distance from ViewPoint to ImagePlane. The point where the perpendicular from ViewPoint to ImagePlane meets ImagePlane is called ImagePlaneCenter and is always seen at the center of the Graphics Window. Note that it follows from the above that ViewDirection is the unit vector pointing in the direction from ViewPoint to ImagePlaneCenter, so in vector notation the following relation holds: ImagePlaneCenter = ViewPoint + FocalLength * ViewDirection.
A positive integer, Scale.
This determines how large an object will look on the computer screen. An interval of unit length on ImagePlane will extend for Scale pixels on the screen.
A positive real number, ClipDistance.
This is the distance from ViewPoint to a plane called ClipPlane that is parallel to ImagePlane and lies between ViewPoint and ImagePlane. (Thus ClipDistance is less than FocalLength, and the ratio of ClipDistance to FocalLength, which is less than one, is called ClipRatio.) The idea is that anything that is behind the ClipPlane should get "clipped", i.e., not rendered when an object is drawn.
A positive real number, EyeSeparation.
This is only relevant for stereo vision, so we will discuss it in the section devoted to that. The ratio of EyeSeparation to FocalLength is called EyeSeparationRatio.

To specify how rendering an object on the monitor takes place, we have to explain two things:

1) How do objects in space get projected to ImagePlane?

2) How does ImagePlane get mapped to the computer screen?

The answer to 1) is very simple. First of all, it is enough to understand how a single point is projected. For then, to project a segment or a polygon we just project the endpoints or vertices---and all the 3-dimensional objects that the program deals with are composed of segments and polygons. But projecting a point is easy---if Orthographic Projection has been chosen from the View menu, then a point is simply orthogonally projected onto ImagePlane. On the other hand, if Perspective has been chosen from the View menu, then a point p is projected to the point q on ImagePlane where the line joining ViewPoint to p meets Imageplane. (Note that q is undefined for points p on the plane through ViewPoint that is parallel to ImagePlane---however, since we only have to worry about points p in front of ClipPlane, this is not a problem.)

The answer to 2) is also easy once we decide how to put coordinate axes on ImagePlane. Since we will choose ImagePlaneCenter as the origin of ImagePlane, the question is how to choose ImagePlaneXDirection and ImagePlaneYDirection---the unit vectors along the positive x-axis and positive y-axis of ImagePlane. Since we will want ViewDirection, ImagePlaneXDirection, and ImagePlaneYDirection to be a right hand coordinate system, it is enough to say how ImagePlaneYDirection is determined. Since the y-axis of ImagePlane will be mapped to the vertical direction on the screen, there is a "natural" choice for ImagePlaneYDirection. Namely, we want "up" on the screen to correspond to "up" (i.e., the z-direction) in space, so we choose ImagePlaneYDirection by projecting the z-direction orthogonally onto ImagePlane and then normalizing it. Of course this won't work if the z-direction is orthogonal to ImagePlane, i.e., if ViewDirection is z-direction or -z-direction, since in this case its projection will be zero and normalization will fail. In this special case though, ImagePlane is parallel to the x,y-plane and we choose ImagePlaneYDirection to be the y-direction in space. For most purposes this special case is to be avoided and, except as explained in the next paragraph, the program makes sure it doesn't occur. (In particular, if the user tries to set the ViewDirection at less than two degrees from the z-axis using the Aspect menu, the program will overide that choice and choose a direction of 88 degrees.)