home *** CD-ROM | disk | FTP | other *** search
- { COMMENTS.....
- This is a demo of a simple isometric drawing procedure. It is a decent
- representation of a 3-d drawing on a 2-d plane. The two procedures of
- interest are plot3d and draw3d. These can be used as direct replacements
- of the turbo pascal plot and draw procedures. The procedures use an X,Y,Z
- system where the Y axis is at angle theta. Theta is given in radians
- where there are about 6.2832 radians in every 360 degrees. The demo
- will draw a circle on the Z = 0 plane, then draw another circle on the
- Z = 29. Then it draws a series of lines parallal to the Z axis with
- endpoints on each of the circles. This requires a color graphics system.
-
- The demo itself is of no importance. However, I hope that the plot3d
- and draw3d procedures will get others interested in three dimensional
- graphics. It's pretty simple and a lot more fun than working with a
- flat screen.
- }
-
-
-
- program ThreeDdemo;
- var i :integer;
-
- procedure plot3d(x,y,z:real);
- const theta = 0.5;
- var a,b:integer;
- begin
- a:= 320+round(x+y*cos(theta));
- b:= 120-round(y*sin(theta)+z);
- plot(a,b,15);
- end;
-
- procedure draw3d(x1,y1,z1,x2,y2,z2:real);
- const theta = 0.5;
- var a,b,c,d:integer;
- begin
- a:= 320+round(x1+y1*cos(theta));
- b:= 120-round(y1*sin(theta)+z1);
- c:= 320+round(x2+y2*cos(theta));
- d:= 120-round(y2*sin(theta)+z2);
- draw(a,b,c,d,15);
- end;
-
-
-
- begin
- hires;
- hirescolor(blue);
- { .........draw one circle }
- for i := 1 to round(20*2*Pi) do
- begin
- draw3d(200*cos(i/20)+25,100*sin(i/20)+25,0,
- 200*cos((i+1)/20)+25,100*sin((i+1)/20)+25,0);
- end;
-
- { .........draw another circle }
- for i := 1 to round(20*2*Pi) do
- begin
- draw3d(200*cos(i/20)+25,100*sin(i/20)+25,29,
- 200*cos((i+1)/20)+25,100*sin((i+1)/20)+25,29);
- end;
-
- { .........draw the lines }
- for i := 1 to round(20*2*Pi) do
- begin
- draw3d(200*cos(i/20)+25,100*sin(i/20)+25,0,200*cos(i/20)+25,
- 100*sin(i/20)+25,29);
- end;
- end.