лабы 2 семестр / 8 лаба
.docПермский Государственный Технический Университет
Кафедра ИТАС
Лабораторная №8
Выполнил: Никулин М.С
Проверил : Мосиенко А. Ю.
Пермь. 2008 г.
Uses Crt, Graph;
Type
SpaceIndex = record
x,y,z: Integer;
End;
Const
LineColor = White;
SectionColor = Yellow;
Ox = 320; Oy = 300;
Border = 30; dt = 5;
Var i: Byte;
Driver,Mode,a,l,hs,H: Integer;
Plane: array[1..12] of PointType;
Space: array[1..12] of SpaceIndex;
Procedure Calculate;
Begin
{Записываем в массив Space координаты
вершин фигуры в пространстве}
{Y}
For i:=1 to 12 Do
if i>8 then With Space[i] Do y:= H+l
Else if i>4 then With Space[i] Do y:= H
Else if i>0 then With Space[i] Do y:= H+hs;
{X}
For i:=1 to 12 Do
if (i mod 4 = 0) or (i mod 4 = 1)
then With Space[i] Do x:= a
Else With Space[i] Do x:= 0;
{Z}
For i:=1 to 12 Do
if (i mod 4 = 1) or (i mod 4 = 2)
then With Space[i] Do z:= 0
Else With Space[i] Do z:= a;
{Пересчитываем их в координаты на плоскости}
For i:=1 to 12 Do Begin
Plane[i].x:= Ox + Round(
(Space[i].y - Space[i].x)*cos(Pi/6));
Plane[i].y:= Oy + Round(
(Space[i].y + Space[i].x)*sin(Pi/6))- Space[i].z;
End;
End;
Procedure DrawFigure;
Begin
Driver:= Detect;
InitGraph(Driver,Mode,'');
{Сечение}
SetColor(SectionColor);
SetFillStyle(LtSlashFill,SectionColor);
FillPoly(4,Plane);
{Сама фигура}
SetColor(LineColor);
Line(Plane[5].x, Plane[5].y, Plane[6].x, Plane[6].y);
Line(Plane[6].x, Plane[6].y, Plane[7].x, Plane[7].y);
Line(Plane[7].x, Plane[7].y, Plane[8].x, Plane[8].y);
Line(Plane[8].x, Plane[8].y, Plane[5].x, Plane[5].y);
Line(Plane[9].x, Plane[9].y, Plane[10].x, Plane[10].y);
Line(Plane[10].x, Plane[10].y, Plane[11].x, Plane[11].y);
Line(Plane[11].x, Plane[11].y, Plane[12].x, Plane[12].y);
Line(Plane[12].x, Plane[12].y, Plane[9].x, Plane[9].y);
Line(Plane[5].x, Plane[5].y, Plane[9].x, Plane[9].y);
Line(Plane[6].x, Plane[6].y, Plane[10].x, Plane[10].y);
Line(Plane[7].x, Plane[7].y, Plane[11].x, Plane[11].y);
Line(Plane[8].x, Plane[8].y, Plane[12].x, Plane[12].y);
{Оси}
H:= Oy - Border;
Line(Ox,Oy,Ox,Border);
Line(Ox,Oy,Ox+Round(H*cos(Pi/6)),Oy+Round(H*sin(Pi/6)));
Line(Ox,Oy,Ox-Round(H*cos(Pi/6)),Oy+Round(H*sin(Pi/6)));
{Надписи}
OutTextXY(Ox+dt,Oy-dt,'0');
OutTextXY(Ox+dt,Border,'z');
OutTextXY(Ox+Round(H*cos(Pi/6))+dt,Oy+Round(H*sin(Pi/6)),'y');
OutTextXY(Ox-Round(H*cos(Pi/6))+dt,Oy+Round(H*sin(Pi/6)),'x');
End;
Procedure EnterandCheck;
Begin
ClrScr;
Write('Ребро основания: '); ReadLn(a);
Write('Боковое ребро: '); ReadLn(l);
Write('Высота сечения: '); ReadLn(hs);
Write('Высота фигуры над XOZ: '); ReadLn(H);
if (a>Oy-Border) or (hs>l)
or (Oy+Round((a+l+H)*cos(Pi/3))>480-Border)
then Begin
TextColor(Red);
Writeln('Слишком большие значения!');
if a>Oy-Border then
WriteLn('Ребро основания, равное ',a,
', больше предельного значения ',Oy-Border,'.');
if Oy+Round((a+l+H)*cos(Pi/3))>480-Border then
WriteLn('Нижняя точка имеет ординату ',
Oy+Round((a+l+H)*cos(Pi/3)),
', превышающую предльное значение ',480-Border,'.');
if hs>l then
WriteLn('Сечение выходит запределы фигуры.');
TextColor(LightGray);
ReadKey;
End Else {Замена процедуры Halt}
begin
Calculate;
DrawFigure;
ReadKey;
End;
End;
Begin
EnterandCheck;
End.