Graphics
Sphere In Cube  Lab Report
Show Various Views of a Sphere in a Cube

Purpose
"Sphere in Cube" shows six perspective views and three orthographic views of a sphere inside a cube.

Materials and Equipment

Software Requirements
Windows 95
Delphi 3 (to recompile)
SphereInCube.EXE

Hardware Requirements
VGA display

Procedure

  1. Double click on the SphereInCube.EXE icon to start the program.
  2. With the Dynamic checkbox checked, press the Draw button.
  3. Press the Clear button and uncheck the Dynamic checkbox.
  4. Press the Draw button again.
  5. If desired, press the Write BMP button to create a 600-by-600 pixel Spheres.BMP file.
  6. If desired, press the Print button to print a full-page of the various views of the sphere in a cube in landscape orientation.

Discussion
The DrawNineViews routine uses various viewports to draw a 3-by-3 matrix of views. The top row shows orthographic views, X-Y, X-Z and Y-Z, while the middle and bottom rows show various perspective views. When the Draw button is pressed, DrawNineViews is called twice to fill the two TImages, ImageBig and ImageSmall.

FillRect is used by the Clear button method to clear both TImages.

The TPantograph class needs documentation so others can use it effectively.

Conclusions
This example shows how to show various orthographic and perspective views of a sphere in a cube using the TPantograph object that maps real-world coordinates to a viewport area.


Keywords
2D/3D vector graphics, translation, rotation, scaling, view transform, homogeneous coordinates, clipping, projections, vectors, matrices, pOrthoXY, pOrthoXZ, pOrthoYZ, pPerspective, TPantograph, Delphi 3

Download
Delphi 3 Source and EXE (139 KB): SphereInCube.ZIP

No change to compile in Delphi 4. EXE size is 229 KB in D3 while it's 319 KB in D4.


Updated
26 Feb 2005


since 1 Nov 1998