### The Camera

This section defines a function which behaves like a hand-held video camera. The camera captures an image from the perspective of the viewer and has the ability to move throughout a scene. For our animation, the camera moves with the slider.

Figure 1 illustrates our method of designing this camera. The box shown represents Mathematica's bounding box for three-dimensional graphics. At the plane is a red circle which represents the lens of our camera. Inscribed in this lens is a blue rectangle. This will represent our viewport or the area where the image of interest will occur. You may wish to interpret this viewport as your monitor.

Also shown is Mathematica's viewpoint (green) in a global or user coordinate system. Dashed lines connect the viewpoint to the corners of the viewport and the back corners of the bounding box. The tetrahedron from the back corner of the bounding box to the viewport is our view volume. Anything within this volume will be visible in the viewport. This represents our camera.

Our camera is fixed in space. If we had decided instead to move our viewpoint, the clipping planes defined by the bounding box could sometimes delete portions of the image we wish to see. Instead motion is provided by moving the objects we wish to view to the viewport and providing the proper angular orientation. The viewer sitting at a computer monitor will not be able to tell the difference.

A simple example shows how the camera operates. Our example will have two graphics objects. One will be a rectangle the size of the viewport at . The other will be a rectangle at the far end of the bounding box. These planes represent the front and rear clipping planes, respectively. With our camera properly oriented, the front clipping plane should just eclipse the back clipping plane.

Our rectangles are dependant on the location of the viewpoint. The viewpoint, `vp`, is defined to be on the x axis but the x location, `xvp`, can be anywhere greater than zero.

To give a visually pleasing display, we will choose the aspect ratio of the viewport to be the `GoldenRatio`. We can now define the lines connecting the viewpoint to the corner of the viewport as a function of position along the x axis.

Here is the definition of our rectangles.

Here is a plot of our two rectangles. The blue rectangle represents the viewport and the red rectangle represents the rear clipping plane. They are located at zero and 10 in this example.

Our next step will be to map the display data to be between x equals zero and minus one. The mapping will occur linearly along a line connecting the data to the viewpoint (the line of sight) so as to not alter the image in the viewport. The function `AffineShape` was used as a template for our function called `LOSAffineShape`. To save execution time, only points with x values less than zero are scaled.

Values greater than zero are clipped by the function `Clip3D`. This function is available in the package `ExtendGraphics`Geometry3D``. This is available from MathSource or included in [1]. If you have a DOS/Windows based system you will have to execute the following lines after copying the package to the proper directories.

Since we are now in our normalized bounding box, we will fix the box ratios and plot range.

Here is a plot of our normalized data.

Our next step is to move our viewpoint to the x axis. Here is a plot of our data from this new viewpoint. Facegrids have been added for perspective and the axes have been turned off.

Our next step is to properly locate the viewpoint along the x axis. This is accomplished by the function `ViewPointFromUser` in the package `ExtendGraphics`View3D'`.

Our transformed viewpoint is given as `vpcam`.

Here is our data viewed at the proper viewpoint. Clearly, the viewport is eclipsing the rear clipping plane.

Our final step shall be to display only the viewport. This is accomplished by setting the `PlotRegion` with the function `pregn`. In this function, `dm` is the change in magnification from one and `zf` is a zoom factor. You may consider this to be an aesthetic factor. A device factor less than one will show more of the image and is equivalent to having the lens inside the viewport rather than the converse.

Here is our final display. It is easily verified that our front clipping plane is just eclipsing our rear and that we are only displaying the contents of the viewport.

Comparison of this image to the previous shows that the edge thickness of the polygons also scale up as the magnification is increased. When the camera is used, it will be important to set the point, line, and edge thicknesses to a minimum or else they may overwrite the graphics.

We capture the demonstration from above in the function `showcamera`.

Rather than moving the camera to the scene, we move the scene to the camera. The function `placeobj` translates the graphics to the center of the lens and then provides the proper attitude. The center of the lens is at the origin. The camera y axis is to the right and the z axis is up. The x axis is toward the viewer. The order of transformation to the proper position and attitude is designed to be intuitive. The user of a hand-held video camera will first move to position and then rotate about the vertical axis to line up his subject. Then he will set the pitch angle followed by roll. The transformations embedded in `placeobj` occur in the same order. A positive camera yaw angle is equivalent to rotating the camera to the right. A positive camera pitch angle is the same as rotating the camera up. A positive camera roll angle rotates the camera clockwise about the axis of the lens.

The camera and motion ability are combined giving the function `mathcam`.

Converted by Mathematica

[Article Index] [Prev Page][Next Page]