For a 3d game i need a function to rotate an euler representation around an arbitary axis by an angle.

For example an object is rotated with euler angles (0,90,0). Now the object should be rotated by 100 degrees around the axis (0,1,0). The resulting angle will be (0,190,0) using rotation order YXZ.

In this case I can add the angle to the euler value of the axis, however for an arbitary axis this will not work.

Problem with Quaternions & Rotation matrices: With these representations the resulting rotations will always be smaller that 180 for each axis. I need the rotation to be lerped afterwards for example from (0,0,0) to (0,720,0).

Basically I am searching for a way to display euler angles like most of the 3D editors. When you rotate an object around any arbitary axis rotation might be larger than 360 in the editor, like (420,720,15).

  • \$\begingroup\$ This sounds like a recipe for extreme pain and suffering, with unsatisfactory results. If you want to rotate beyond 360 degrees (quaternions can go beyond 180 on their own), then your best bet is to store your rotational travel as an axis-angle pair. Euler angles do not lerp well, so using them as your basis is unlikely to give you the behaviour you want. \$\endgroup\$
    – DMGregory
    Sep 30, 2020 at 15:38
  • \$\begingroup\$ Thank you! That is a good idea. I would like to display the rotation values in the game aswell and an angle-axis pair is confusion at first unfortunatelly. Most 3D editors also do not interpolate values perfectly, but that is fine for my case. Do you have an idea how 3D editors caluclate euler values from an angle and axis? \$\endgroup\$ Sep 30, 2020 at 17:09
  • \$\begingroup\$ They usually store a matrix or quaternion internally, and express it as a set of Euler angles for serialization and display only. When the user changes those Euler angles individually, the engine calculates a new quaternion/matrix from them. When the user manipulates the object in a non-Euler-angle-based way, like rotating about an arbitrary axis, that change is done with quaternions/matrices, then converted back to Euler angles in a clamped range (so a 720 degree rotation would typically be overwritten with a 0) \$\endgroup\$
    – DMGregory
    Sep 30, 2020 at 18:01


You must log in to answer this question.

Browse other questions tagged .