13. 3-D Prisms


General Description

This program has been designed to allow the user to rotate a 3-D prism on the screen. You can create your own prism by altering the data statement in line 2000 (see detailed notes below).

Detailed Description

   Lines 5 and 60 First part of delete trick.
   10-50 Display title.
   70-90 Asks for number of sides to that prism, e.g. a square prism has four sides.
   Ask for size to display on screen.
   Ask for steps, (this is for rotation).
Note: Validation is not carried out on the above inputs because the user can modify the data line.
   100-110 Displays the page giving list of instructions.
   120 Converts angle from degrees to radians.
   130-180 Sets up variables and reads data for prism.
   190 Transfer shape through Z-plane.
   200-290 Display each end of prism.
   300-360 This is the procedure to transfer shape along Z-plane by two units. (At line 340)
   370-410 Join both ends of prism together.
   420-570 Get input from keyboard.
   580-650 Rotates about Y-axis using rotation matrix.
      X' = X COS Q - Z SIN Q
      Z' = Z COS Q - X SIN Q
      Y' = Y
   660-730 Rotates about X-axis using matrix.
      X' = X
      Y' = Y COS Q + Z SIN Q
      Z' = Z COS Q - X SIN Q
   740-810 Rotate about Z-axis using matrix.
      X' = X COS Q + Y SIN Q
      Y' = Y COS Q - X SIN Q
      Z' = Z
   820-970 Displays help page, and gives a list of instructions.
   980-1050 Gives instructions.
   1060-1067 Second part of delete trick.
   1070-1120 Credits.
   2000 Is the data for the prism.
Note: To change shape of prism, change line 2000. The data at line 2000 is in the format
 
X,Y X,Y X,Y X,Y
First corner Second corner Third corner  Fourth corner
Plot shape on graph paper with origin going through middle of the object.

Educational Notes

Whilst this program has an obvious role in clarifying descriptions in geometry lesson, it's also a wonderful demonstration of the potential of computer graphics!