Вычерчивание проволочной модели трапеции(Delphi 10)
Добавлено: 02 июн 2013, 16:26
программа для вычерчивания куба, нужно переделать под трапецию(обязательно в Delphi10),на форме должны быть кнопки масштабирования и поворота, за денюжку возьмется кто ?
Код: Выделить всё
uses graph;
const h=100;
var x,GrD,GrM: integer;
EO,dst:integer;
fi,teta:integer;
f,t:real;
x0,y0:word;
v11,v12,v13,
v21,v22,v23,
v32,v33,
v43:real;
px,py:word;
graphDriver,GraphMode:integer;
function ex(x:integer):word;
begin ex:=x+x0; end;
Function ey(y:integer):word;
begin ey:=GetMaxY-(y0+y); end;
Procedure koeff;
var k, th,ph:real;
begin
k:=Pi/180;
th:=k*teta; ph:=k*fi;
v11:=-sin(th); v12:=-cos(ph)*cos(th); v13:=-sin(ph)*cos(th);
v21:=cos(th); v22:=-cos(ph)*sin(th); v23:=-sin(ph)*sin(th);
v32:=sin(ph); v33:=-cos(ph);
v43:=eo;
end;
Procedure Perspective(x,y,z: integer; var px,py:word);
var c1,c2:word;
xe,ye,ze:real;
Begin
c1:= GetMaxX div 2;
c2:= GetMaxY div 2;
{координаты глаза } xe:=v11*x+v21*y;
ye:=v12*x+v22*y+v32*z;
ze:=v13*x+v23*y+v33*z+v43;
{экранные координаты} px:=Round(dst*xe/ze+c1);
py:=Round(dst*ye/ze+c2);
end;
Procedure dw (x,y,z:integer);
Begin
perspective(x,y,z,px,py);
lineto(px,py);
{ lineto(ex(px),ey(py)); }
end;
Procedure mv(x,y,z:integer);
begin
perspective(x,y,z,px,py);
moveto(px,py);
{moveto(ex(px),ey(py));}
end;
Begin
writeln('Eo='); Readln(eo);
writeln('fi=');Readln(fi);
writeln('Teta='); Readln(teta);
writeln(расстояние наблюдатель - экран'); readln(dst);
graphDriver:=detect;
initgraph(graphDriver,graphMode,'');
x:=GraphResult;
If x=GrOk Then
Begin
X0:=GetMaxx div 2;
Y0:=GetMaxY div 2;
koeff{(Eo,teta,fi)};
mv(h,-h,-h);dw(h,h,-h);
dw(-h,h,-h);
dw(-h,h,h);
dw(-h,-h,h);
dw(h,-h,h);
dw(h,-h,-h);
mv(h,h,-h); dw(h,h,h);
dw(-h,h,h);
mv(h,h,h);dw(h,-h,h);
mv(h,-h,-h); dw(-h,-h,-h);
dw(-h,h,-h);
mv(-h,-h,-h);dw(-h,-h,h);
{ Line(100,120, 300,300);}
End
Else
Writeln('x=',x);
Readln;
end.