Seite 1 von 1

Rotationsmatrix aus Normale erstellen

Verfasst: 10.07.2009, 20:20
von DomiOh
Hallo,

ich benötige eine Möglichkeit, eine Rotationsmatrix aus einer Normalen zu erstellen, um z.B. eine Fläche an einer anderen auszurichten. Die Drehung der Fläche ist mir aber nicht bekannt, daher möchte ich gerne eine Rotationsmatrix aus der Normalen der Fläche erstellen.
Ich habe viel probiert und auch viel gegoogelt, jedoch keine (verständliche) Lösung gefunden.

Weiß jemand Rat?

Re: Rotationsmatrix aus Normale erstellen

Verfasst: 11.07.2009, 11:19
von Ingrater
Du kannst aus der Normalen eine beliebige Anzahl von Rotationsmatrizen erstellen da mindestens 2 Vektoren benötigt werden um eine eindeutige Rotation festzulegen. Du brüchtest also zur Normalen noch die Tangente oder Binormale, dann kannst du mit einem Kreuzprodukt den 3. Vektor errechnen und aus diesen 3 Vektoren die Rotationsmatrix bauen.

Re: Rotationsmatrix aus Normale erstellen

Verfasst: 11.07.2009, 11:47
von Zudomon
Hi!

Code: Alles auswählen

function GetRotMatrix(const _v: TVec3): TMatrix;
var
  x, y, z: TVec3;
begin
  z:=nrm(_v);
  if abs(dot(z,Vec(0,1,0)))<0.99 then y:=Vec(0,1,0) else y:=Vec(1,0,0);
  x:=nrm(crs(y, z));
  y:=nrm(crs(z, x));

  Result:=MatIdentity;
  Result.SetAxisX(x);
  Result.SetAxisY(y);
  Result.SetAxisZ(z);
end;
wobei die Set Methoden folgende sind:

Code: Alles auswählen

    property AxisX_x: single read mMatrix._11 write mMatrix._11;
    property AxisX_y: single read mMatrix._12 write mMatrix._12;
    property AxisX_z: single read mMatrix._13 write mMatrix._13;

    property AxisY_x: single read mMatrix._21 write mMatrix._21;
    property AxisY_y: single read mMatrix._22 write mMatrix._22;
    property AxisY_z: single read mMatrix._23 write mMatrix._23;

    property AxisZ_x: single read mMatrix._31 write mMatrix._31;
    property AxisZ_y: single read mMatrix._32 write mMatrix._32;
    property AxisZ_z: single read mMatrix._33 write mMatrix._33;
Das ganze für Direct3D Matrizen.

Gruß
Zudo

Re: Rotationsmatrix aus Normale erstellen

Verfasst: 11.07.2009, 19:41
von DomiOh
Man dankt :-)