Thema: Delphi 3D-Rotation

Einzelnen Beitrag anzeigen

eyeless

Registriert seit: 12. Aug 2005
49 Beiträge
 
#1

3D-Rotation

  Alt 8. Feb 2006, 23:19
Servus!

So, da ich jez mal angefangen habe, einen eigenen 3D-Plotter zu basteln, tritt schon das 1. Problem auf: irgendwie funz die Rotation noch nicht ganz ... aber fast ...

Das ganze hab ich mit Hilfe der Einheitsmatrix gemacht:

Rotatiom um die x-Axe:
( 1 0 0 0)
( 0 cos sin 0)
( 0 -sin cos 0)
( 0 0 0 1)

Rotatiom um die y-Axe:
( cos 0 -sin 0)
( 0 1 0 0)
( sin 0 cos 0)
( 0 0 0 1)


Rotatiom um die z-Axe:
( cos sin 0 0)
(-sin cos 0 0)
( 0 0 1 0)
( 0 0 0 1)

daraus folgt:

Delphi-Quellcode:
procedure rotVertex(G1,G2,G3 : double; var V : TSimpleVertex);
begin
  //x-Axe
  V.x := V.x*1+ V.y*0+ V.z*0;
  V.y := V.x*0+ V.y*cos(G1)+ V.z*sin(G1);
  V.z := V.x*0+ -V.y*sin(G1)+ V.z*cos(G1);

  //y-Axe
  V.x := V.x*cos(G2)+ V.y*0+ -V.z*sin(G2);
  V.y := V.x*0+ V.y*1+ V.z*0;
  V.z := V.x*sin(G2)+ V.y*0+ V.z*cos(G2);

  //z-Axe
  V.x := V.x*cos(G3)+ V.y*sin(G3)+ V.z*0;
  V.y := -V.x*sin(G3)+ V.y*cos(G3)+ V.z*0;
  V.z := V.x*0+ V.y*0+ V.z*1;
end;
Eigentlich foll logistisch, ABER:

1. Selbst wen ich einen Winkel von 1 Grad nehme, spielt das Ding verrückt.
2. Wenn ich nun mal Werte nehme, die sehr klein (z.B. 0,05), dass funzt es, allerdings Wird das Objekt dann immer kleiner
3. Einfach Bsp anguggen ...

Den Würfel habe ich gedreht, indem ich jeden einzelnen Punkt um den 0-Punkt drehe, da dieser auch der Schwerpukt des Würfels ist (was dann noch zu lösen ist, wie ich das Ding um seinen eigenen Schwerpunkt drehe, hab aber schon ne Idee)

Delphi-Quellcode:
procedure rotPoly(G1,G2,G3 : double; var P : TSimplePolygon); //ein Polygon hat einfach 3 Punkte ...
begin
  rotVertex(G1,G2,G3,P.P1);
  rotVertex(G1,G2,G3,P.P2);
  rotVertex(G1,G2,G3,P.P3);
end;

procedure TCube.trans(T : TSimpleVertex); // dder Würfel hat 12 Polys ...
var
  i : Integer;
begin
  for i := 0 to 11 do
  begin
    transPoly(T,Polys[i]);
  end;
end;
Kann mir da jemand helfen ... Bitte?

Noch ein Prob: Da es unter delphi 2005 kein DoubleBuffered bei der PaintBox gibt .. was kann ich also machen, um das Flackern zu killen? ... hat sich erledigt musste ja nur in der OnCreate DoubleBuffered auf true setzen. ... sorry.

mfg, eyeless
Angehängte Dateien
Dateityp: rar 3d-rot-w32_498.rar (163,1 KB, 34x aufgerufen)
Dateityp: exe 3d-rot-dotnet_505.exe (20,0 KB, 15x aufgerufen)
  Mit Zitat antworten Zitat