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,
To give a visually pleasing display, we will choose the aspect ratio of the viewport to be the
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
Values greater than zero are clipped by the function
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
Our transformed viewpoint is given as
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
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
Rather than moving the camera to the scene, we move the scene to the camera. The function
The camera and motion ability are combined giving the function
Converted by Mathematica