While trying to answer another SO question, the issue of how to calculate Euler angles for dimensions > 3 came up. The RSpincalc
package has a straightforward DCM2EA
function for converting a 3d rotation matrix to Euler or Tait-Bryan angles, but this only handles the specific case of 3 dimensions. The wikipedia page on Euler angles briefly discusses the issue of extending Euler angles to higher dimensions and cites an Italian paper which apparently generalises the method to greater numbers of dimensions. Unfortunately, neither my Italian nor my maths are quite up to taking that paper and creating a usable R function.
My current method, used in this answer is a little cumbersome, to say the least. I use the Ryacas
package to create a symbolic matrix which is the composite of a series of rotations for an arbitrary number of dimensions. This can then be solved iteratively against a known rotation matrix to find the angles required. It works, but it gets increasingly slow once the number of dimensions is 5 or more.
Is there a better way to achieve this objective, either through implementation of the method in the Italian paper or something else?
The relative orientation between two orthogonal righthanded 3D cartesian coordinate systems, let's call them xyz and ABC, is described by a real orthogonal 3x3 rotation matrix R, which is commonly parameterized by three so-called Euler angles α, β and γ.
Given a rotation matrix R, we can compute the Euler angles, ψ, θ, and φ by equating each element in R with the corresponding element in the matrix product Rz(φ)Ry(θ)Rx(ψ). This results in nine equations that can be used to find the Euler angles. Starting with R31, we find R31 = − sin θ. are valid solutions.
It is the convention normally used for aerospace applications, so that zero degrees elevation represents the horizontal attitude. Tait–Bryan angles represent the orientation of the aircraft with respect to the world frame. When dealing with other vehicles, different axes conventions are possible.
rotm = eul2rotm( eul , sequence ) converts Euler angles to a rotation matrix, rotm . The Euler angles are specified in the axis rotation sequence, sequence . The default order for Euler angle rotations is "ZYX" .
There is an interesting paper here from 1972 that addresses the issue of computing N-dimensional Euler angles given an N-dimensional orthogonal matrix (which I assume is what you have). I skimmed the paper and it gives formulas for what you seem to need:
I did not try to re-derive and validate their equations but they give explicit formulas so you could implement them for low-dimensions for which you already have answers and see if they agree.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With