Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Problem bei Rotation (https://www.delphipraxis.net/86340-problem-bei-rotation.html)

3_of_8 12. Feb 2007 20:52


Problem bei Rotation
 
Morgen.

Ich versuche gerade, einen Vektor um den Nullpunkt rotieren zu lassen.

Mein Ansatz:

Delphi-Quellcode:
procedure TMCCamera.TurnAround(const Pitch, Yaw: Single);
var Vector: TVector;
    Matrix: TMatrix;
begin
  //Berechnen der Rotationsmatrix, bisherige Rotationsmatrix wird mit den Rotationsmatrizen
  //der übergebenen Winkel multipliziert
  FRotMatrix:=MatrixMultiply(FRotMatrix,
      CreateRotationMatrix(MakeAffineVector([1, 0, 0]), Pitch/180*Pi));
  FRotMatrix:=MatrixMultiply(FRotMatrix,
      CreateRotationMatrix(MakeAffineVector([0, 1, 0]), Yaw/180*Pi));

  //Positionsvektor wird mit den Rotationsmatrizen der übergebenen Winkel multipliziert
  Matrix:=IdentityMatrix;
  Matrix:=MatrixMultiply(Matrix,
      CreateTranslationMatrix(MakeVector([FX, FY, FZ, 1])));
  Matrix:=MatrixMultiply(Matrix,
      CreateRotationMatrix(MakeAffineVector([1, 0, 0]), Pitch/180*Pi));
  Matrix:=MatrixMultiply(Matrix,
      CreateRotationMatrix(MakeAffineVector([0, 1, 0]), Yaw/180*Pi));    

  //Übernehmen der Positionswerte
  FX:=Matrix[3, 0];
  FY:=Matrix[3, 1];
  FZ:=Matrix[3, 2];

end;
Das ganze soll etwa so aussehen, dass bei das Feld erst um Yaw nach rechts/links gedreht wird und dann um Pitch nach oben/unten.

Also wenn man ein Blatt Papier nimmt, und es wird TurnAround(45, 90) aufgerufen, dann soll das Blatt erst um 90° nach links gedreht werden und dann um 45° nach unten.

Bei meinem Code ist es aber eher so, als würde das ganze erst um 90° nach rechts und dann um 45° nach links gerollt werden.


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:32 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz