четверг, 23 декабря 2010 г.

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

Код программы.
  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 p: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:real;

begin
Xmax:=110;
   Ymin:=-110;
   Ymax:=110;
   Xmin:=-90;
   Image1.Canvas.Rectangle(0, 0, Image1.Width, Image1.Height);
   Image1.Canvas.pen.Color := clblue;
   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:=clblue;
   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));

   p[1,1]:=StrtoInt(Edit1.Text);
p[1,2]:=StrtoInt(Edit2.Text);
p[2,1]:=StrtoInt(Edit3.Text);
p[2,2]:=StrtoInt(Edit4.Text);
    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]*p[g,j];
     end;
   Image1.Canvas.pen.Color := clwhite;
   Image1.Canvas.Rectangle(0, 0, Image1.Width, Image1.Height);
   Image1.Canvas.pen.Color := clblue;
   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;    

Интерфейс.





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

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