Professional Documents
Culture Documents
Graficación - Proyección Paralela
Graficación - Proyección Paralela
Docente
Trabajo
Segundero
Estudiante
19 de noviembre de 2022
Código:
unit UCubo;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TFcubo3d = class(TForm)
img: TImage;
pn1: TPanel;
Bzmenos: TButton;
Bzmas: TButton;
Bxmenos: TButton;
Bxmas: TButton;
Bymenos: TButton;
Bymas: TButton;
Bdib: TButton;
Blimp: TButton;
procedure FormCreate(Sender: TObject);
procedure IniciarFigura();
procedure EscalarFigura(Numx : Integer; Numy : Integer; NumZ : Integer);
procedure DibujarFigura(Sender : TObject);
procedure TrasladarMedioPantalla(Sender : TObject);
procedure BdibClick(Sender: TObject);
procedure Limpiar(Sender : TObject);
procedure RotarZmas(Sender : TObject);
procedure RotarZmenos(Sender : TObject);
procedure RotarXmas(Sender : TObject);
procedure RotarXmenos(Sender : TObject);
procedure RotarYmas(Sender : TObject);
procedure RotarYmenos(Sender : TObject);
procedure BzmenosClick(Sender: TObject);
procedure BzmasClick(Sender: TObject);
procedure BxmenosClick(Sender: TObject);
procedure BxmasClick(Sender: TObject);
procedure BymenosClick(Sender: TObject);
procedure BymasClick(Sender: TObject);
procedure BlimpClick(Sender: TObject);
procedure ProyParalela( x, y, z: Real; var xP, yP : Integer );
private
{ Private declarations }
public
{ Public declarations }
end;
type
TPoint3D = packed record
x : Real;
y : Real;
z : Real;
end;
var
Fcubo3d: TFcubo3d;
var
Cubo : Array [1..10] of TPoint3D;
P, Q : TPoint;
xaux, yaux, zaux : Real;
i, angulo : Integer;
alfa: Real;
xm, ym : Integer;
implementation
{$R *.dfm}
procedure TFCubo3d.IniciarFigura();
begin
procedure TFcubo3d.ProyParalela(x: Real; y: Real; z: Real; var xP: Integer; var yP: Integer);
begin
xP := Round( x ) + xm;
yP := Round( y ) + ym;
end;
img.Canvas.Pen.Color := clblue;
img.Canvas.Brush.Color := clblue;
for i := 5 to 8 do
begin
if i = 8 then
begin
ProyParalela( Cubo[i].x, Cubo[i].y, Cubo[i].z, P.x, P.y );
ProyParalela( Cubo[5].x, Cubo[5].y, Cubo[5].z, Q.x, Q.y );
img.Canvas.MoveTo(P.X, P.Y);
img.Canvas.LineTo(Q.X, Q.Y);
end
else
begin
ProyParalela( Cubo[i].x, Cubo[i].y, Cubo[i].z, P.x, P.y );
ProyParalela( Cubo[i+1].x, Cubo[i+1].y, Cubo[i+1].z, Q.x, Q.y );
img.Canvas.MoveTo(P.X, P.Y);
img.Canvas.LineTo(Q.X, Q.Y);
end;
end;
img.Canvas.Pen.Color := clblack;
img.Canvas.Brush.Color := clblack;
img.Canvas.Pen.Color := clred;
img.Canvas.Brush.Color := clred;
for i := 1 to 4 do
begin
if i = 4 then
begin
ProyParalela( Cubo[i].x, Cubo[i].y, Cubo[i].z, P.x, P.y );
ProyParalela( Cubo[1].x, Cubo[1].y, Cubo[1].z, Q.x, Q.y );
img.Canvas.MoveTo(P.X, P.Y);
img.Canvas.LineTo(Q.X, Q.Y);
end
else
begin
ProyParalela( Cubo[i].x, Cubo[i].y, Cubo[i].z, P.x, P.y );
ProyParalela( Cubo[i+1].x, Cubo[i+1].y, Cubo[i+1].z, Q.x, Q.y );
img.Canvas.MoveTo(P.X, P.Y);
img.Canvas.LineTo(Q.X, Q.Y);
end;
end;
img.Canvas.Pen.Color := clblack;
img.Canvas.Brush.Color := clblack;
img.Canvas.Pen.Color := clgreen;
img.Canvas.Brush.Color := clgreen;
for i := 1 to 4 do
begin
ProyParalela( Cubo[i].x, Cubo[i].y, Cubo[i].z, P.x, P.y );
ProyParalela( Cubo[i+4].x, Cubo[i+4].y, Cubo[i+4].z, Q.x, Q.y );
img.Canvas.MoveTo(P.X, P.Y);
img.Canvas.LineTo(Q.X, Q.Y);
end;
img.Canvas.Pen.Color := clblack;
img.Canvas.Brush.Color := clblack;
end;
end.
https://youtu.be/PMlbWkiGAlY