пятница, 24 декабря 2010 г.

Лабораторная работа №10.

Код программы.
procedure TForm1.Button1Click(Sender: TObject);
 const n=6;l=2;
       m: array[1..n,1..l]of real=((15,15),(15,40),(25,40),(20,35),(25,30),(15,30));
  var p1,p2,p3:array[1..l,1..l] of real;
      pn:array[1..n,1..l] of real;
      i,j,g,OXsc,OYsc:integer;
      kx,ky,Xmax,Ymin,Ymax,Xmin,ugol:real;
  begin

   Xmax:=100;
   Ymin:=-100;
   Ymax:=100;
   Xmin:=-100;
   Image1.Canvas.Rectangle(0, 0, Image1.Width, Image1.Height);
   Image1.Canvas.pen.Color := clred;
   kx:=Image1.Width/(Xmax-Xmin);
   ky:=Image1.Height/(Ymax-Ymin);
   OXsc:=Round((0-Xmin)*kx);
   OYsc:=Round(Image1.Height-(0-Ymin)*ky);
   Image1.Canvas.MoveTo(OXsc,0);
   Image1.Canvas.LineTo(OXsc,Image1.Height);
   Image1.Canvas.MoveTo(0,OYsc);
   Image1.Canvas.LineTo(Image1.Width,OYsc);
   Image1.Canvas.Pen.Color:=clgreen;
   Image1.canvas.moveto(Round((m[1,1]-Xmin)*kx),Round(Image1.Height-(m[1,2]-Ymin)*ky));
   for i:=2 to n do
      Image1.canvas.lineto(Round((m[i,1]-Xmin)*kx),Round(Image1.Height-(m[i,2]-Ymin)*ky));
   ugol:=(StrtoInt(Edit1.Text))*(pi/180);
   p1[1,1]:=cos(ugol);
   p1[1,2]:=sin(ugol);
   p1[2,1]:=-sin(ugol);
   p1[2,2]:=cos(ugol);
   p2[1,1]:=StrtoInt(Edit2.Text);
   p2[1,2]:=StrtoInt(Edit3.Text);
   p2[2,1]:=StrtoInt(Edit4.Text);
   p2[2,2]:=StrtoInt(Edit5.Text);
    for i:=1 to l do
     for j:=1 to l do
    begin
     p3[i,j]:=0;
      for g:=1 to l do
        p3[i,j]:=p3[i,j]+p1[i,g]*p2[g,j];
    end;
    for i:=1 to n do
     for j:=1 to l do
    begin
     pn[i,j]:=0;
      for g:=1 to l do
        pn[i,j]:=pn[i,j]+m[i,g]*p3[g,j];
     end;
     Image1.Canvas.pen.Color := clblack;
   Image1.Canvas.Rectangle(0, 0, Image1.Width, Image1.Height);
   Image1.Canvas.pen.Color := clgreen;
   Image1.Canvas.MoveTo(OXsc,0);
   Image1.Canvas.LineTo(OXsc,Image1.Height);
   Image1.Canvas.MoveTo(0,OYsc);
   Image1.Canvas.LineTo(Image1.Width,OYsc);
   Image1.canvas.moveto(Round((pn[1,1]-Xmin)*kx),Round(Image1.Height-(pn[1,2]-Ymin)*ky));
 for i:=2 to n do
    Image1.canvas.lineto(Round((pn[i,1]-Xmin)*kx),Round(Image1.Height-(pn[i,2]-Ymin)*ky));
end;
                                 Интерфейс.


 

Комментариев нет:

Отправить комментарий