uses Graph,Crt,Wgc; type XY=record x, y: real; end; DrawP=object Kf : Array [1..4] of Integer; Current,Sim : Array [1..4] of XY; Koht : Array [1..4] of Byte; A,B,Kkf,An : Real; Procedure LoadXY(K1,Koht1, K2,Koht2, K3,Koht3, K4,Koht4 : Integer); Procedure UDRL(L : Integer); Procedure UpDown(L : Integer); Procedure RightLeft(L : Integer); Procedure Rotate(L : Integer); Procedure DrawEll(X,Y : Integer); end; Procedure DrawP.LoadXY; begin Kf[1]:=K1; Koht[1]:=Koht1; Kf[2]:=K2; Koht[2]:=Koht2; Kf[3]:=K3; Koht[3]:=Koht3; Kf[4]:=K4; Koht[4]:=Koht4; end; Procedure DrawP.DrawEll; Var K : Byte; begin For K:=1 to 3 do begin if (Current[K].Y < Current[K+1].Y) then SetLineStyle(1,0,1) else SetLineStyle(0,0,1); Line(Round(KKf*Current[K].X)+X, Round(KKf*Current[K].Y)+Y, Round(KKf*Current[K+1].X)+X, Round(KKf*Current[K+1].Y)+Y); Line(Round(KKf*Sim[K].X)+X, Round(KKf*Sim[K].Y)+Y, Round(KKf*Sim[K+1].X)+X, Round(KKf*Sim[K+1].Y)+Y); end; SetLineStyle(0,0,1); if (Current[4].Y < Current[1].Y) then SetLineStyle(1,0,1); Line(Round(KKf*Current[4].X)+X, Round(KKf*Current[4].Y)+Y, Round(KKf*Current[1].X)+X, Round(KKf*Current[1].Y)+Y); if (Current[4].Y < Current[1].Y) then SetLineStyle(1,0,1); Line(Round(KKf*Sim[4].X)+X, Round(KKf*Sim[4].Y)+Y, Round(KKf*Sim[1].X)+X, Round(KKf*Sim[1].Y)+Y); For K:=2 to 3 do begin if (Current[K-1].Y < Current[K].Y) and (Current[K].Y < Current[K+1].Y) then SetLineStyle(1,0,1) else SetLineStyle(0,0,1); Line(Round(KKf*Current[K].X)+X, Round(KKf*Current[K].Y)+Y, Round(KKf*Sim[K].X)+X, Round(KKf*Sim[K].Y)+Y); end; if (Current[4].Y < Current[1].Y) and (Current[1].Y < Current[2].Y) then SetLineStyle(1,0,1) else SetLineStyle(0,0,1); Line(Round(KKf*Current[1].X)+X, Round(KKf*Current[1].Y)+Y, Round(KKf*Sim[1].X)+X, Round(KKf*Sim[1].Y)+Y); if (Current[3].Y < Current[4].Y) and (Current[4].Y < Current[1].Y) then SetLineStyle(1,0,1) else SetLineStyle(0,0,1); Line(Round(KKf*Current[4].X)+X, Round(KKf*Current[4].Y)+Y, Round(KKf*Sim[4].X)+X, Round(KKf*Sim[4].Y)+Y); end; Procedure DrawP.UDRL; begin case L of 1,3 : DrawP.RightLeft(L); 2,4 : DrawP.UpDown(L); 44,46,60,62 : DrawP.Rotate(L); end; end; Procedure DrawP.UpDown; Var K : Byte; begin For K:=1 to 4 do if (Abs(Round(1000*Current[K].Y))=51637) or (Abs(Round(1000*Current[K].Y))=51638) then begin if (Current[K].Y < 0) and (L=2) then If Koht[K]=1 then Koht[K]:=0; if (Current[K].Y > 0) and (L=2) then If Koht[K]=0 then Koht[K]:=1; if (Current[K].Y < 0) and (L=4) then If Koht[K]=0 then Koht[K]:=1; if (Current[K].Y > 0) and (L=4) then If Koht[K]=1 then Koht[K]:=0; end; For K:=1 to 4 do if L=2 then if Kf[K]<358 then Kf[K]:=Kf[K]+3 else Kf[K]:=0 else if Kf[K]>-358 then Kf[K]:=Kf[K]-3 else Kf[K]:=0; For K:=1 to 4 do Current[K].Y:=( (100*Sin(Pi*Kf[K]/180))+(-(-200-(100*Cos(Pi*Kf[K]/180))) * (100*Sin(Pi*Kf[K]/180)) / (-400-(100*Cos(Pi*Kf[K]/180) )) ) ); For K:=1 to 4 do if Koht[K]=0 then Current[K].X:= A / B * (Sqrt (Sqr(B)-Sqr(Current[K].Y)) ) else Current[K].X:= -A / B * (Sqrt (Sqr(B)-Sqr(Current[K].Y)) ); {OutText(StrS(Round(Abs(1000*Current[2].Y)))); OutTextXY(0,20,StrS(Koht[2])); For K:=1 to 4 do OutTextXY(Round(Current[k].X)+250,Round(1.5*Current[K].Y)+240, StrS(Koht[K]) ); For K:=1 to 4 do OutTextXY(Round(Current[k].X)+200,Round(1.5*Current[K].Y)+240,StrS(K)+' '+Strs(Round(Current[K].Y)+230) ); } For K:=1 to 4 do Sim[K].Y:=Current[K].Y; For K:=1 to 4 do Sim[K].X:=Current[K].X*-1+80; end; Procedure DrawP.RightLeft; Var K : Byte; Temp : Real; begin if L=1 then KKf:=KKf+0.05; if L=3 then KKf:=KKf-0.05; end; Procedure DrawP.Rotate; Var Temp : Array[1..4] of XY; K : Byte; begin case L of 44,60 : An:=An+1; 46,62 : An:=An-1; end; For K:=1 to 4 do begin Temp[K].X:=Round( (Current[K].X-Round(40*KKf))*Cos(An*Pi/180)+Current[K].Y*Sin(An*Pi/180)); Temp[K].Y:=Round(Current[K].Y*Cos(An*Pi/180)-(Current[K].X-Round(40*KKf))*Sin(An*Pi/180)); end; For K:=1 to 4 do Circle(Round(KKf*Temp[K].X)+320{+Round(40*KKf)}, Round(KKf*Temp[K].Y)+240, 5); end; var d, m, L : Integer; KB : DrawP; Temp : Array[1..4] of XY; begin d:=VGA; M:=2; initgraph(d, m, 'c:\bp\bgi'); KB.KKf:=2; KB.A:=10; KB.B:=51.63749; KB.LoadXY(45,0, 135,1, -135,1, -45,0); SetColor(2); repeat L:=RKey; ClearDevice; KB.UDRL(L); KB.DrawEll(320-Round(40*KB.KKf),240); until L=27; CloseGraph; end.