![]() |
Problem bei Rotation
Morgen.
Ich versuche gerade, einen Vektor um den Nullpunkt rotieren zu lassen. Mein Ansatz:
Delphi-Quellcode:
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.
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; 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 03:22 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz