Написать паскаль-программу которая строит поверхность x^2/a^2+y^2/b^2-z^2/c^2=-1 Написала, но когда ввожу коефициненты a,b,c программа не хочет дальше выполнять действия вот код
| Код | uses crt,graph;
const distan=5;
el=5000;
type point3D=record
x,y,z:Single;
end;
var dr,md,i,alf:integer;
m,shag,x,y,z,a,b,c,r,fi:real;
key:string;
FIG:array [1..el] of Point3D;
osX,osY,osZ:array [1..3] of point3D;
{********************* ДЦ╜╙Ф╗╗,╒╝╖╒Ю═И═НИ╗╔ ╞Ю╝╔╙Ф╗Н БЮЯЕ╛╔Ю╜╝╘ Б╝Г╙╗ ╜═ ╞╚╝А╙╝АБЛ ********************}
function Get3Dx(x,z:Single):integer;
begin
Get3Dx:=round(320+(x*distan/(distan+z/100)))
end;
function Get3dy(y,z:Single):integer;
begin
Get3Dy:=round(240+(y*distan/(distan+z/100)))
end;
{************************************ Ю╗А╝╒═╜╗╔ БЮЯЕ╛╔Ю╜╝╘ Б╝Г╙╗ **************************************}
procedure Pixel3D(t:point3D;color:byte);
begin
PutPixel( Get3Dx(t.x,t.z) , get3Dy(t.y,t.z) ,color);
end;
{************************************ ╞╔Ю╔╝╓ ёЮ═╓ЦА╝╒ ╒ Ю═╓╗═╜К ***************************************}
function Grad(Gradus:Single):real;
Begin
Grad:=(Gradus*pi)/180;
end;
{*************************************** ╒Ю═И╔╜╗╔ ╞╝ ╝АО╛ x,y,z ***************************************}
procedure RotPz(var t:point3D;alfa:integer);
var t1:point3D;
begin
t1:=t;
t.x:=t1.x*cos(grad(alfa))-t1.y*sin(grad(alfa));
t.y:=t1.x*sin(grad(alfa))+t1.y*cos(grad(alfa));
t.z:=t1.z;
end;
procedure RotPy(var t:point3D;alfa:integer);
var t1:point3D;
begin
t1:=t;
t.x:=t1.x*cos(grad(alfa))-t1.z*sin(grad(alfa));
t.z:=t1.x*sin(grad(alfa))+t1.z*cos(grad(alfa));
t.y:=t1.y;
end;
procedure RotPx(var t:point3D;alfa:integer);
var t1:point3D;
begin
t1:=t;
t.z:=t1.z*cos(grad(alfa))-t1.y*sin(grad(alfa));
t.y:=t1.z*sin(grad(alfa))+t1.y*cos(grad(alfa));
t.x:=t1.x;
end;
{****************************************** ╛═АХБ═║╗Ю╝╒═╜╗╔ *******************************************}
procedure Mashtab(var t:Point3D;msh:single);
begin
t.x:=t.x*msh;
t.y:=t.y*msh;
t.z:=t.z*msh;
end;
{******************************************************************************************************}
begin
clrscr;
writeln('risovanie poverhnosti x^2/a^2 + y^2/b^2 - z^2/c^2 = -1');
writeln;
writeln('dlja vraschenija grafika ispolzujte klaviwi:');
writeln(' w,s po osi x');
writeln(' a,d po osi y');
writeln(' q,e po osi z');
write('vvedite koefficient a i nazhmite enter: ');
readln(a);
write('vvedite koefficient b i nazhmite enter: ');
readln(b);
write('vvedite koefficient c i nazhmite enter: ');
readln©;
{********************************************* ╗╜╗Ф╗═╚╗╖═Ф╗О ёЮ═Д╗╙╗ **********************************}
dr:=detect;
InitGraph (dr,md,' ');
if GraphResult<>GrOK then halt;
{******************************************************************************************************}
i:=0;
r:=1;
shag:=r/10; {Х═ё Б═║Ц╚╗Ю╝╒═╜╗О}
{*************************** Б═║Ц╚╗Ю╝╒═╜╗╔ ╗ А╝ЕЮ═╜╔╜╗╔ Б╝Г╔╙ ╒ ╛═АА╗╒ - "FIG" ************************}
y:=-abs(r*b);
repeat
x:=-abs(r*a);
repeat
i:=i+1;
x:=x+shag;
if ((1+(sqr(x))/(sqr(a))+(sqr(y))/(sqr(b))) >=0) then
begin
fig[i].x:=x;
fig[i].y:=y;
fig[i].z:=-sqrt(abs((sqr©)*(1+(sqr(x))/(sqr(a))+(sqr(y))/(sqr(b)))));
inc(i);
fig[i].x:=x;
fig[i].y:=y;
fig[i].z:= sqrt(abs((sqr©)*(1+(sqr(x))/(sqr(a))+(sqr(y))/(sqr(b)))));
end;
until x>=abs(r*a);
y:=y+shag;
until y>=abs(r*b);
{************************************ ╙╝╝Ю╓╗╜═БК ╝А╔╘ ╙╝╝Ю╓╗╜═Б ****************************************}
osX[1].x:=0;osX[1].y:=0;osX[1].z:=0;osX[2].x:=240;osX[2].y:=0;osX[2].z:=0;
osY[1].x:=0;osY[1].y:=0;osY[1].z:=0;osY[2].x:=0;osY[2].y:=-240;osY[2].z:=0;
osZ[1].x:=0;osZ[1].y:=0;osZ[1].z:=0;osZ[2].x:=0;osZ[2].y:=0;osZ[2].z:=240;
{************************************* ╙╝╝Ю╓╗╜═Б╒ ║Ц╙╒ ╜═ ╝АОЕ *****************************************}
osX[3].x:=240;osX[3].y:=0;osX[3].z:=0;
osY[3].x:=0;osY[3].y:=-240;osY[3].z:=0;
osZ[3].x:=0;osZ[3].y:=0;osZ[3].z:=240;
key:=' ';
{************************************* ╝А╜╝╒╜╝╘ Ф╗╙╚ ╞Ю╝ёЮ═╛╛К *****************************************}
repeat
{************************************** ╞╝АБЮ╝╔╜╗╔ ╝А╔╘ ╗ ║Ц╙╒ *****************************************}
outtextXY(get3Dx(osX[3].x,osX[3].z),get3Dy(osX[3].y,osX[3].z),'X');
outtextXY(get3Dx(osY[3].x,osY[3].z),get3Dy(osY[3].y,osY[3].z),'Y');
outtextXY(get3Dx(osZ[3].x,osZ[3].z),get3Dy(osZ[3].y,osZ[3].z),'Z');
setcolor(6);
line(get3Dx(osX[1].x,osX[1].z),get3Dy(osX[1].y,osX[1].z),
get3Dx(osX[2].x,osX[2].z),get3Dy(osX[2].y,osX[2].z));
setcolor(4);
line(get3Dx(osY[1].x,osY[1].z),get3Dy(osY[1].y,osY[1].z),
get3DX(osY[2].x,osY[2].z),get3Dy(osY[2].y,osY[2].z));
setcolor(3);
line(get3Dx(osZ[1].x,osZ[1].z),get3Dy(osZ[1].y,osZ[1].z),
get3Dx(osZ[2].x,osZ[2].z),get3Dy(osZ[2].y,osZ[2].z));
{************************************** Ю╗А╝╒═╜╗╔ ╞╝╒╔ЮЕ╜╝АБ╗ ******************************************}
for i:=1 to el do
begin
pixel3D(fig[i],2);
end;
alf:=0;
m:=0;
key:=readkey;
cleardevice;
{************************************ Ю╔═ё╗Ю╝╒═╜╗╔ ╜═ ╙╚═╒╗═БЦЮЦ ****************************************}
if (key='w') or (key='s') then
begin
if key='s' then Alf:=5;
if key='w' then Alf:=-5;
for i:=1 to 3 do
begin
rotPx(osY[i],alf);
rotPx(osZ[i],alf);
rotPx(osX[i],alf);
end;
for i:=1 to el do
rotPx(fig[i],alf);
end;
if (key='a') or (key='d') then
begin
if key='a' then alf:=5;
if key='d' then alf:=-5;
for i:=1 to 3 do
begin
rotPy(osX[i],alf);
rotPy(osZ[i],alf);
rotPy(osY[i],alf);
end;
for i:=1 to el do
rotPy(fig[i],alf);
end;
if (key='q')or (key='e') then
begin
if key='q' then alf:=5;
if key='e' then alf:=-5;
for i:=1 to 3 do
begin
rotPz(osX[i],alf);
rotPz(osY[i],alf);
rotPz(osZ[i],alf);
end;
for i:=1 to el do
rotPz(fig[i],alf);
end;
if (key='+') or (key='-') then
begin
if key='+' then m:=1.5;
if key='-' then m:=0.5;
for i:=1 to el do
Mashtab(fig[i],m);
end;
until
key=#27;
CloseGraph;
end.
|
в чем тут ошибка ???
M THandle | Модератор: используйте подсветку кода! |
|