home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MADTRB34.ZIP / THREED.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1986-04-25  |  2.1 KB  |  69 lines

  1. {  COMMENTS.....
  2.     This is a demo of a simple isometric drawing procedure.  It is a decent
  3.     representation of a 3-d drawing on a 2-d plane.  The two procedures of
  4.     interest are plot3d and draw3d.  These can be used as direct replacements
  5.     of the turbo pascal plot and draw procedures.  The procedures use an X,Y,Z
  6.     system where the Y axis is at angle theta.  Theta is given in radians
  7.     where there are about 6.2832 radians in every 360 degrees.  The demo
  8.     will draw a circle on the Z = 0 plane, then draw another circle on the
  9.     Z = 29.  Then it draws a series of lines parallal to the Z axis with
  10.     endpoints on each of the circles.  This requires a color graphics system.
  11.  
  12.     The demo itself is of no importance.  However, I hope that the plot3d
  13.     and draw3d procedures will get others interested in three dimensional
  14.     graphics.  It's pretty simple and a lot more fun than working with a
  15.     flat screen.
  16. }
  17.  
  18.  
  19.  
  20. program ThreeDdemo;
  21. var i  :integer;
  22.  
  23. procedure plot3d(x,y,z:real);
  24. const theta = 0.5;
  25. var a,b:integer;
  26. begin
  27.  a:= 320+round(x+y*cos(theta));
  28.  b:= 120-round(y*sin(theta)+z);
  29.  plot(a,b,15);
  30. end;
  31.  
  32. procedure draw3d(x1,y1,z1,x2,y2,z2:real);
  33. const theta = 0.5;
  34. var   a,b,c,d:integer;
  35. begin
  36.  a:= 320+round(x1+y1*cos(theta));
  37.  b:= 120-round(y1*sin(theta)+z1);
  38.  c:= 320+round(x2+y2*cos(theta));
  39.  d:= 120-round(y2*sin(theta)+z2);
  40.  draw(a,b,c,d,15);
  41.  end;
  42.  
  43.  
  44.  
  45. begin
  46.  hires;
  47.  hirescolor(blue);
  48. {                             .........draw one circle }
  49.  for i := 1 to round(20*2*Pi) do
  50.   begin
  51.    draw3d(200*cos(i/20)+25,100*sin(i/20)+25,0,
  52.             200*cos((i+1)/20)+25,100*sin((i+1)/20)+25,0);
  53.   end;
  54.  
  55. {                             .........draw another circle }
  56.  for i := 1 to round(20*2*Pi) do
  57.   begin
  58.    draw3d(200*cos(i/20)+25,100*sin(i/20)+25,29,
  59.             200*cos((i+1)/20)+25,100*sin((i+1)/20)+25,29);
  60.   end;
  61.  
  62. {                             .........draw the lines }
  63.  for i := 1 to round(20*2*Pi) do
  64.   begin
  65.    draw3d(200*cos(i/20)+25,100*sin(i/20)+25,0,200*cos(i/20)+25,
  66.    100*sin(i/20)+25,29);
  67.   end;
  68. end.
  69.