Euler Angles as provided by Florin Herinean
The following is provided as a courtesy to the world by Florin Herinean.
I've (Florin) worked in the past days on an algorithm to get the euler angles (or roll, pitch, yaw) from a Transform3D, which is missing at the moment from the j3d api. Since it seems that i'm finally getting reliable results on it, I want to share my work with you all. The algorithm is adapted on the theoretical paper "Computing Euler angles from a rotation matrix" by Gregory G. Slabaugh - the original one wasn't working due to floating point errors.
TransformAnalyzer ta = new TransformAnalyzer();
ta.setTransform(<your transform>); //pass in a Transform3D
Vector3d eulers = ta.getEuler();
1. doesn't produce euler angles at all if the transform contains shears.
2. in case of reflection transform, the angles are computed relative to the reflected transform around (0, 0, 0).
For those singular cases, the TransformAnalyzer provides the following methods:
- analyze() - throws EulerException if the transform contains shears or the
Euler angles could not be computed for whatever reasons.
- isShear() - true if there was an exception due to shears.
- isValidEuler() - true if there is at least one valid set of Euler angles.
- isReflection() - true if the set of Euler angles is relative to the reflection around (0, 0, 0).