Program Kub;
Uses Graph,Crt;
Type
mas=array[1..8] of real;
Var
ro,teta,phi,d,rebro:real;
xk,yk,zk:mas;
xv,yv,zv:mas;
V:array [1..4,1..4] of real;
i,GrDrive,GrMode:integer;
minx,miny,maxx,maxy,fx,fy,f,c1,c2:real;
t,f1,wx1,wy1,wx2,wy2:integer;
q:char;
Function mult(x,y,z:real; n:integer):real;
Begin
xv[n]:=x*v[1,1]+y*v[2,1]+z*v[3,1]+v[4,1];
yv[n]:=x*v[1,2]+y*v[2,2]+z*v[3,2]+v[4,2];
zv[n]:=x*v[1,3]+y*v[2,3]+z*v[3,3]+v[4,3];
End;
Begin
GrDrive:=Detect;
InitGraph(GrDrive,GrMode,'');
t:=0;
f1:=0;
d:=1400;
Repeat
SetColor(0);
line(round(xv[1]),round(yv[1]),round(xv[2]),round(yv[2]));
line(round(xv[2]),round(yv[2]),round(xv[3]),round(yv[3]));
line(round(xv[3]),round(yv[3]),round(xv[4]),round(yv[4]));
line(round(xv[4]),round(yv[4]),round(xv[1]),round(yv[1]));
line(round(xv[5]),round(yv[5]),round(xv[6]),round(yv[6]));
line(round(xv[6]),round(yv[6]),round(xv[7]),round(yv[7]));
line(round(xv[7]),round(yv[7]),round(xv[8]),round(yv[8]));
line(round(xv[8]),round(yv[8]),round(xv[5]),round(yv[5]));
line(round(xv[1]),round(yv[1]),round(xv[5]),round(yv[5]));
line(round(xv[2]),round(yv[2]),round(xv[6]),round(yv[6]));
line(round(xv[3]),round(yv[3]),round(xv[7]),round(yv[7]));
line(round(xv[4]),round(yv[4]),round(xv[8]),round(yv[8]));
rebro:=100;
ro:=1360;
t:=t+1;
f1:=f1+1;
if t=90 then t:=0;
if f1=90 then f1:=0;
teta:=t*pi/180;
phi:=f1*pi/180;
xk[1]:=rebro; yk[1]:=-rebro; zk[1]:=-rebro;
xk[2]:=rebro; yk[2]:=rebro; zk[2]:=-rebro;
xk[3]:=-rebro; yk[3]:=rebro; zk[3]:=-rebro;
xk[4]:=-rebro; yk[4]:=-rebro; zk[4]:=-rebro;
xk[5]:=rebro; yk[5]:=-rebro; zk[5]:=rebro;
xk[6]:=rebro; yk[6]:=rebro; zk[6]:=rebro;
xk[7]:=-rebro; yk[7]:=rebro; zk[7]:=rebro;
xk[8]:=-rebro; yk[8]:=-rebro; zk[8]:=rebro;
v[1,1]:=-sin(teta); v[1,2]:=-cos(phi)*cos(teta); v[1,3]:=-sin(phi)*cos(teta);
v[2,1]:=cos(teta); v[2,2]:=-cos(phi)*sin(teta); v[2,3]:=-sin(phi)*sin(teta);
v[3,1]:=0; v[3,2]:=sin(phi); v[3,3]:=-cos(phi);
v[4,1]:=0; v[4,2]:=0; v[4,3]:=ro;
for i:=1 to 8 do
begin
mult(xk[i],yk[i],zk[i],i);
xv[i]:=d*xv[i]/zv[i];
yv[i]:=d*yv[i]/zv[i];
end;
SetViewPort(250,200,350,300,false);
SetColor(10);
line(round(xv[1]),round(yv[1]),round(xv[2]),round(yv[2]));
line(round(xv[2]),round(yv[2]),round(xv[3]),round(yv[3]));
line(round(xv[3]),round(yv[3]),round(xv[4]),round(yv[4]));
line(round(xv[4]),round(yv[4]),round(xv[1]),round(yv[1]));
line(round(xv[5]),round(yv[5]),round(xv[6]),round(yv[6]));
line(round(xv[6]),round(yv[6]),round(xv[7]),round(yv[7]));
line(round(xv[7]),round(yv[7]),round(xv[8]),round(yv[8]));
line(round(xv[8]),round(yv[8]),round(xv[5]),round(yv[5]));
line(round(xv[1]),round(yv[1]),round(xv[5]),round(yv[5]));
line(round(xv[2]),round(yv[2]),round(xv[6]),round(yv[6]));
line(round(xv[3]),round(yv[3]),round(xv[7]),round(yv[7]));
line(round(xv[4]),round(yv[4]),round(xv[8]),round(yv[8]));
delay(1000);
Until KeyPressed;
CloseGraph;
End.
автор ЛоРД_Оледжан (http://www.cyberforum.ru/)
Uses Graph,Crt;
Type
mas=array[1..8] of real;
Var
ro,teta,phi,d,rebro:real;
xk,yk,zk:mas;
xv,yv,zv:mas;
V:array [1..4,1..4] of real;
i,GrDrive,GrMode:integer;
minx,miny,maxx,maxy,fx,fy,f,c1,c2:real;
t,f1,wx1,wy1,wx2,wy2:integer;
q:char;
Function mult(x,y,z:real; n:integer):real;
Begin
xv[n]:=x*v[1,1]+y*v[2,1]+z*v[3,1]+v[4,1];
yv[n]:=x*v[1,2]+y*v[2,2]+z*v[3,2]+v[4,2];
zv[n]:=x*v[1,3]+y*v[2,3]+z*v[3,3]+v[4,3];
End;
Begin
GrDrive:=Detect;
InitGraph(GrDrive,GrMode,'');
t:=0;
f1:=0;
d:=1400;
Repeat
SetColor(0);
line(round(xv[1]),round(yv[1]),round(xv[2]),round(yv[2]));
line(round(xv[2]),round(yv[2]),round(xv[3]),round(yv[3]));
line(round(xv[3]),round(yv[3]),round(xv[4]),round(yv[4]));
line(round(xv[4]),round(yv[4]),round(xv[1]),round(yv[1]));
line(round(xv[5]),round(yv[5]),round(xv[6]),round(yv[6]));
line(round(xv[6]),round(yv[6]),round(xv[7]),round(yv[7]));
line(round(xv[7]),round(yv[7]),round(xv[8]),round(yv[8]));
line(round(xv[8]),round(yv[8]),round(xv[5]),round(yv[5]));
line(round(xv[1]),round(yv[1]),round(xv[5]),round(yv[5]));
line(round(xv[2]),round(yv[2]),round(xv[6]),round(yv[6]));
line(round(xv[3]),round(yv[3]),round(xv[7]),round(yv[7]));
line(round(xv[4]),round(yv[4]),round(xv[8]),round(yv[8]));
rebro:=100;
ro:=1360;
t:=t+1;
f1:=f1+1;
if t=90 then t:=0;
if f1=90 then f1:=0;
teta:=t*pi/180;
phi:=f1*pi/180;
xk[1]:=rebro; yk[1]:=-rebro; zk[1]:=-rebro;
xk[2]:=rebro; yk[2]:=rebro; zk[2]:=-rebro;
xk[3]:=-rebro; yk[3]:=rebro; zk[3]:=-rebro;
xk[4]:=-rebro; yk[4]:=-rebro; zk[4]:=-rebro;
xk[5]:=rebro; yk[5]:=-rebro; zk[5]:=rebro;
xk[6]:=rebro; yk[6]:=rebro; zk[6]:=rebro;
xk[7]:=-rebro; yk[7]:=rebro; zk[7]:=rebro;
xk[8]:=-rebro; yk[8]:=-rebro; zk[8]:=rebro;
v[1,1]:=-sin(teta); v[1,2]:=-cos(phi)*cos(teta); v[1,3]:=-sin(phi)*cos(teta);
v[2,1]:=cos(teta); v[2,2]:=-cos(phi)*sin(teta); v[2,3]:=-sin(phi)*sin(teta);
v[3,1]:=0; v[3,2]:=sin(phi); v[3,3]:=-cos(phi);
v[4,1]:=0; v[4,2]:=0; v[4,3]:=ro;
for i:=1 to 8 do
begin
mult(xk[i],yk[i],zk[i],i);
xv[i]:=d*xv[i]/zv[i];
yv[i]:=d*yv[i]/zv[i];
end;
SetViewPort(250,200,350,300,false);
SetColor(10);
line(round(xv[1]),round(yv[1]),round(xv[2]),round(yv[2]));
line(round(xv[2]),round(yv[2]),round(xv[3]),round(yv[3]));
line(round(xv[3]),round(yv[3]),round(xv[4]),round(yv[4]));
line(round(xv[4]),round(yv[4]),round(xv[1]),round(yv[1]));
line(round(xv[5]),round(yv[5]),round(xv[6]),round(yv[6]));
line(round(xv[6]),round(yv[6]),round(xv[7]),round(yv[7]));
line(round(xv[7]),round(yv[7]),round(xv[8]),round(yv[8]));
line(round(xv[8]),round(yv[8]),round(xv[5]),round(yv[5]));
line(round(xv[1]),round(yv[1]),round(xv[5]),round(yv[5]));
line(round(xv[2]),round(yv[2]),round(xv[6]),round(yv[6]));
line(round(xv[3]),round(yv[3]),round(xv[7]),round(yv[7]));
line(round(xv[4]),round(yv[4]),round(xv[8]),round(yv[8]));
delay(1000);
Until KeyPressed;
CloseGraph;
End.
автор ЛоРД_Оледжан (http://www.cyberforum.ru/)
Комментариев нет:
Отправить комментарий