GR3D
Plot a three-dimensional graph with hidden line removal.

Program:   GR3D
Author:    John P. Powers  (jpp@cpdvax.csc.ti.com)
Date:      March 19, 1992.
Synopsis:  GR3D plots a three-dimensional graph on the TI-85
           calculator.

Instructions:

1)  Modify GR3DEQ to compute z as a function of x and y.  GR3DEQ
    already contains some equations to get you started.  To use one
    of the starter equations, change the Goto at the beginning to
    jump to one of them.

2)  Modify GR3D to set the coordiates of the observer (XE, YE, ZE),
    the x and y domain (XL, XH, YL, YH) and the grid density (GRID).
    You don't need to change these values to get some reasonable
    graphs.

3)  Run GR3D from the home screen.

There are three subroutines which accompany the main routine:
  GR3DEQ - define your equation here,
  GR3DPLOT - Wright's hidden-line removal algorithm,
  GR3DLEFT - auxiliary routine for GR3DPLOT.

Several variables in GR3D are pre-defined:
  XE=2, YE=1, ZE=1 are the coordinates of the observer's eye.

  XL=-7, XH=7, YL=-7, XH=7 are the limits of the domain for x and y
      input to the function to be graphed.  The current settings
      create a graph centered at the origin.

  GRID=11 is the grid density of the graph.  This setting will create
      an eleven by eleven square graph.  A lower setting will produce
      a faster but courser picture.  High settings take longer and
      begin to clutter the TI-85 screen as the fairly low device
      resolution is approached.

GR3D first builds matrices of transformed and projected coordinates
for function values at the grid point intersections.  The program
displays a count down to zero as these matrices are computed.  The
program then scales the transformed points to fit the entire graph
on the screen.  Finally the graph is drawn with hidden lines removed.

The entire process takes about 5.5 minutes.

GR3DEQ contains four equations for a starter.  Change the Goto in the
first line of this program to Goto EQ1, ..., EQ4 to select which
equation should be plotted.

EQ1:  z = cos |x+y*i|
      XL=-7, XH=7, YL=-7, YH=7 (set these in GR3D)
      Radians mode.
      See picture COSXY.

EQ2:  z = e^-|x-1+y*i| + e^-|x+1+y*i|
      XL=-2.5, XH=2.5, YL=-2.5, YH=2.5
      See picture EXPXY2.

EQ3:  z = R - sqrt(1-(x^2+y^2)),	if norm [x,y,R] < 1.
	  		      0,	otherwise.
      XL=-1.2, XH=1.2, YL=-1.2, YH=1.2
      R=.7  (This could be set once in GR3D.)
      This creates a depression in the plane z=0 by pressing a sphere
      into its surface.  R is a fraction in the domain [0,1] which
      indicates the depth that a unit radius sphere is pressed into
      the plane.  See picture SPHERE3D.

EQ4:  z = e^-|x+y*i|
      XL=-1.2, XH=1.2, YL=-1.2, YH=1.2
      See picture EXPXY.

Memory requirements:
   PROGRAMS
  GR3D	    1548 bytes
  GR3DEQ     186 bytes  This varies according the complexity of F(x,y).
  GR3DLEFT    90 bytes
  GR3DPLOT   845 bytes
  
   REALS
  I, J, K, S, U, V,
  x, y, z,		       135 bytes
  CX, CY, DX, DY,
  S1, S2, S3, S4,
  U1, U2, V1, V2, VK,
  UH, UL, VH, VL,
  KM, KX, VM, VX,
  XL, XH, YL, YH,
  XE, YE, ZE,
  X0, Y0,		       480 bytes
  GRID				18 bytes

   MATRICES and VECTORS
  H         1277 bytes
  L	    1277 bytes
 *RX        1448 bytes
 *RY        1448 bytes
 *X          127 bytes
 *Y          127 bytes

 * These matrices and vectors take up more memory as GRID increases.

Total memory required:  approximately 9006 bytes.

The program releases the space used by the matrices and vectors when
it finishes.
