Autor Beitrag
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 26.03.06 18:01 
Hi erstmal, meine Projektionsfunktion sieht so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
function Projektion(v3d: TVektor3d): TVektor2d;
var
  r1, r2: TVektor3d;
  m3x3: TMatrix3x3;
begin
  m3x3[0, 0] :=               0; m3x3[0, 1] := 0; m3x3[0, 2] := 0;
  m3x3[1, 0] := - (sqrt(2) / 4); m3x3[1, 1] := 1; m3x3[1, 2] := 0;
  m3x3[2, 0] := - (sqrt(2) / 4); m3x3[2, 1] := 0; m3x3[2, 2] := 1;

  matrixrowtovektor_3x3(m3x3, r1, 1);
  matrixrowtovektor_3x3(m3x3, r2, 2);
  
  result.x1 := skalarprodukt_v3d(v3d, r1);
  result.x2 := skalarprodukt_v3d(v3d, r2);
end;

so zeichne ich einen würfel:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
procedure TForm1.DrawCubeLine(a, b: integer);
begin
  image1.Canvas.MoveTo(image1.Width div 2 + round(cube_2d[a].x1), image1.Height div 2 + round(cube_2d[a].x2));
  image1.Canvas.LineTo(image1.Width div 2 + round(cube_2d[b].x1), image1.Height div 2 + round(cube_2d[b].x2));
end;

procedure TForm1.Cube;
var
  i, j: integer;
begin
  image1.canvas.Pen.color := clblack;
  cube_3d[0].x1 :=  0; cube_3d[0].x2 :=  0;  cube_3d[0].x3 :=  0;
  cube_3d[1].x1 :=  0; cube_3d[1].x2 := 50;  cube_3d[1].x3 :=  0;
  cube_3d[2].x1 := 50; cube_3d[2].x2 :=  0;  cube_3d[2].x3 :=  0;
  cube_3d[3].x1 := 50; cube_3d[3].x2 := 50;  cube_3d[3].x3 :=  0;
  cube_3d[4].x1 :=  0; cube_3d[4].x2 :=  0;  cube_3d[4].x3 := 50;
  cube_3d[5].x1 :=  0; cube_3d[5].x2 := 50;  cube_3d[5].x3 := 50;
  cube_3d[6].x1 := 50; cube_3d[6].x2 :=  0;  cube_3d[6].x3 := 50;
  cube_3d[7].x1 := 50; cube_3d[7].x2 := 50;  cube_3d[7].x3 := 50;
  for i := 0 to 7 do
    cube_2d[i] := Projektion(cube_3d[i]);
  DrawCubeLine(0, 1);
  DrawCubeLine(0, 2);
  DrawCubeLine(0, 4);
  DrawCubeLine(1, 3);
  DrawCubeLine(1, 5);
  DrawCubeLine(2, 3);
  DrawCubeLine(2, 6);
  DrawCubeLine(3, 7);
  DrawCubeLine(4, 5);
  DrawCubeLine(4, 6);
  DrawCubeLine(5, 7);
  DrawCubeLine(6, 7);
end;

jedoch ist die perspektive falsch, die x1 geht nach links oben, statt nach links unten weg, die x3 achse nach unten, ich müsste das ganze jetzt also um die x2 achse spiegeln, nur stehe ich mal wieder auf dem schlauch... am besten sollte das schon bei der projektion passieren, dass die x3 achse invertiert wird, jedoch so, dass sich nicht nur der vektor umdreht, sondern eben das komplette koordinatensystem gespiegelt wird.

danke schonmal ;)