home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / basic / fastp12.zip / 3DPLOT.BAS next >
BASIC Source File  |  1993-04-21  |  2KB  |  90 lines

  1. '***********************************************************************
  2. '                           Fast Parser 1.2
  3. '              Copyright (C) 1992, 1993 by Daniel Corbier
  4. '                         All rights reserved.
  5. '
  6. ' This program plots 3D surfaces.
  7. '
  8. ' The x axis is horizontal, the y axis is vertical, and the z axis
  9. ' is perpendicular to the screen.  The surface is plotted in perspective.
  10. '
  11. ' Keep in mind that this simple projection cannot properly display all
  12. ' the equations that you can give it, and there is no hidden surface
  13. ' removal.
  14. '
  15. '***********************************************************************
  16. $Include"calc.inc"
  17.  
  18. Screen 9                      ' Change to Screen 2 if the monitor is CGA
  19. Window (-10,-10)-(10,10)
  20.  
  21. VarName$(0) = "x"             ' This is how you define variable names
  22. VarName$(1) = "y"
  23.  
  24. Print "At the prompt, enter your own equation, or press [enter] for default."
  25.  
  26. For count% = 1 to 16
  27.  
  28.     Read DataEq$
  29.     Print "Enter f(x,y): ["; DataEq$ ;"]  ";
  30.     Line Input Eq$
  31.     If len(Eq$) = 0 then Eq$ = DataEq$
  32.  
  33.     Print Eq$
  34.  
  35.     Ptr% = EqParse%(Eq$)     ' The expression is parsed ahead of time
  36.  
  37.     For x=-10 to 10
  38.         For y=-10 to 10 step .5
  39.             i$=inkey$
  40.             if len(i$) then End
  41.  
  42.             VarValue##(0) = x
  43.             VarValue##(1) = y
  44.             z = Evaluate##(Ptr%)    ' z = f(x,y)
  45.             xx = x*10/(z+13)
  46.             yy = y*10/(z+13)
  47.             if y=-10 then pset(xx,yy) else line -(xx,yy)
  48.         Next
  49.     Next
  50.  
  51.     For y=-10 to 10
  52.         For x=-10 to 10 step .5
  53.             i$=inkey$
  54.             if len(i$) then End
  55.  
  56.             VarValue##(0) = x
  57.             VarValue##(1) = y
  58.             z = Evaluate##(Ptr%)
  59.             xx = x*10/(z+13)
  60.             yy = y*10/(z+13)
  61.             if x=-10 then pset(xx,yy) else line -(xx,yy)
  62.         Next
  63.     Next
  64.  
  65.     Locate 23 : Print "Press any key for the next graph"
  66.     I$=input$(1)
  67.     Cls
  68.  
  69. Next count%
  70.  
  71. DATA sqrt(abs(x*y))
  72. DATA exp(x/10)*sin(y)
  73. DATA x*sin(y)/4
  74. DATA 2*( (x>0)*sin(x) + (y>0)*cos(y) )
  75. DATA sin(x)*x*y/10
  76.  
  77. DATA rnd(x)*y
  78. DATA abs(rnd(x)*y)
  79. DATA rnd(x)*y^2
  80.  
  81. DATA (y>0)*x^2/2^y + (y<0)*2*cos(y)
  82. DATA (x>0)*x^2/2^y + (y<0)*2*cos(y)
  83.  
  84. DATA exp(x/15) xor sin(y)
  85. DATA exp(sin(x)*y/4)
  86. DATA exp(sin(x)*y/4)*cos(y)
  87.  
  88. DATA x mod 5
  89. DATA exp(x mod 5)
  90. DATA exp(x xor y)