unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Tpoint3d =
record
x,y,z:real;
end;
Tcanvas3d =
class(Tcanvas)
Function Calc3d(p:tpoint3d;angle,multi:real):tpoint;
Procedure triangle3d(p1,p2,p3:tpoint3d);
end;
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Function Tcanvas3d.Calc3d(p:tpoint3d;angle,multi:real):tpoint;
begin
result.x:=round(multi*(p.x+p.z*cos(angle)));
result.y:=round(multi*(p.y+p.z*sin(angle)));
end;
Procedure Tcanvas3d.triangle3d(p1,p2,p3:tpoint3d);
var p01:
array [0..2]
of tpoint;
begin
p01[0]:=Calc3d(p1,Pi / 7,1);
p01[1]:=Calc3d(p2,Pi / 7,1);
p01[2]:=Calc3d(p3,Pi / 7,1);
polygon(p01);
// ----->Hier meckert das Programm zur Laufzeit: kann nicht auf auf Leinwand/Bild zeichnen
end;
procedure TForm1.Button1Click(Sender: TObject);
var s:Tcanvas3d;t:tpoint;p1,p2,p3:tpoint3d;
begin
s:=Tcanvas3d.Create;
p1.x:=100;p1.y:=100;p1.z:=0;
p2.x:=200;p2.y:=100;p2.z:=0;
p3.x:=200;p3.y:=150;p3.z:=0;
s.triangle3d(p1,p2,p3);
//canvas.Assign(s);
s.Free;
end;
end.