Richtungswinkel für Matrix
-
Hey!
Ich bin ne NULL in Mathe und muss daher fragen:
Wie rechne ich den Richtungswinkel richtig für eine Matrixtransformation aus? So mache ich es derzeit:atan(playerMoveY / playerMoveX)
Dabei möchte ich gerne einen Pfeil immer in die Bewegungsrichtung drehen. Doch leider rotiert der Pfeil ab 90° um 180°. Wie verhindere ich das?
(Anfangs zeigt der Pfeil nach rechts, sobald er nach Unten und noch ein Pixel nach Links zeigt -> Rotation um 180°, sobald er nach Oben und noch ein Pixel nach Rechts zeigt -> wieder Rotation um 180°)
D3DXMatrixTransformation2D(&playerRotationMatrix, 0, 0, 0, &playerRotationCenter, atan(playerMoveY / playerMoveX), 0);
Danke
MfG
-
Hi ceplusplus,
Edit: atan2(y, x) sollte dein Problem lösen.
Gruß
-
Jo super, danke
MfG