home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
beehive
/
utilitys
/
gifpas.ark
/
TVPLOT.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1992-03-18
|
3KB
|
118 lines
CONST xSize = 512;
ySize = 256;
TYPE xRange = 0..xSize;
yRange = 0..ySize;
PlotRec = RECORD
xB,yB,zB : Real;
xM,yM,zM : Real;
p,q,s,t : Real
END;
VAR xPos,yPos : Integer;
Data3D : PlotRec;
PROCEDURE InitPlot;
BEGIN
Write( #27#27'GZP0;' );
xPos := 0; yPos := 0
END { InitPlot };
FUNCTION xScale(x: Integer):Integer;
BEGIN
xScale := Round(512.0/xSize*x)
END;
FUNCTION yScale(y: Integer):Integer;
BEGIN
yScale := Round(256.0/ySize*y)
END;
PROCEDURE Plot(x,y : Integer);
BEGIN
IF (0 <= x) AND (x <= xSize-1) AND (0 <= y) AND (y <= ySize-1) THEN
BEGIN
Write( 'M',xScale(x),' ',yScale(y),';J0 0;' );
END
END { Plot };
PROCEDURE Line( x1,y1,x2,y2 : Integer );
VAR x,y,z,dx,dy,dz,i1,i2 : Integer;
BEGIN
Write( 'M',xScale(x1),' ',yScale(y1),';D',xScale(x2),' ',yScale(y2),';' );
END { Line };
PROCEDURE PlotAbs(x,y : INTEGER);
BEGIN
Line(xPos,yPos,x,y);
xPos := x; yPos := y
END { PlotAbs };
PROCEDURE PlotRel(dx,dy : Integer);
BEGIN
PlotAbs(xPos + dx, yPos + dy)
END { Plotrel };
PROCEDURE MoveAbs(x,y : Integer);
BEGIN
xPos := x; yPos := y
END { MoveAbs };
PROCEDURE MoveRel(dx,dy : Integer);
BEGIN
xPos := xPos + dx; yPos := yPos + dy
END { MoveRel };
PROCEDURE Cursor(x,y: Integer);
BEGIN
MoveAbs(x,y);
MoveRel(5,0);
PlotRel(-10,0);
MoveRel(5,5);
PlotRel(0,-10);
MoveRel(0,5)
END { Cursor };
PROCEDURE Cursor2(x,y: Integer);
BEGIN
MoveAbs(x,y);
MoveRel(4,4);
PlotRel(-8,-8);
MoveRel(8,0);
PlotRel(-8,8);
MoveRel(4,-4)
END { Cursor2 };
PROCEDURE ViewPoint(xBet,yBet,zBet,xFl,yFl,zFl : Real);
BEGIN
WITH Data3D DO
BEGIN
xB := xBet; yB := yBet; zB := zBet;
xM := xFl; yM := yFl; zM := zFl;
p := Sqrt(Sqr(xM-xB) + Sqr(yM-yB));
q := Sqrt(Sqr(p) + Sqr(zM-zB));
IF p = 0 THEN s := 1 ELSE s := (yM-yB)/p;
IF p = 0 THEN t := 0 ELSE t := (xM-xB)/p
END
END { ViewPoint };
PROCEDURE Calc3D(x,y,z : Real; VAR u,v,r : Real);
BEGIN
WITH Data3D DO
BEGIN
r := (xM-xB)*(x-xB) + (yM-yB)*(y-yB) + (zM-zB)*(z-zB);
u := (s*q*(x-xB) - t*q*(y-yB))/r;
v := (-t*(zM-zB)*(x-xB) - s*(zM-zB)*(y-yB) + p*(z-zB))/r
END
END { Calc3D };
PROCEDURE EndPlot;
BEGIN
WriteLn( 'M450 0;BReady' );
REPEAT UNTIL KeyPressed;
Write( 'ZA' )
END { EndPlot };
PROCEDURE DonePlot;
BEGIN
END { DonePlot };