Class EulerUtil
- Namespace
- Hi.NcParsers.NcWriteback
- Assembly
- HiMech.dll
Decomposes a rotation matrix into euler angles for a configurable
EulerSequence (default Zxz,
the Fanuc G68.2 standard format) such that
new mat4d_t(third, θ3) * new mat4d_t(second, θ2) * new mat4d_t(first, θ1)
reproduces the input — for ZXZ this is the exact composition
IsoG68p2TiltSyntax performs when parsing
G68.2 X_ Y_ Z_ I_ J_ K_, so a synthesized command round-trips to
the same ProgramToMcTransform
tilt entry.
The sequence is configurable because real controllers interpret tilted plane commands with controller-dependent conventions (Fanuc G68.2 P formats, Siemens CYCLE800, Heidenhain PLANE SPATIAL); pick the sequence the target controller expects. Note the replaying parse side (IsoG68p2TiltSyntax) currently reads ZXZ only — in-project replay parity holds for the ZXZ default.
Implementation: the input is conjugated by a signed axis-permutation rotation into the family's canonical frame (ZXZ for proper-euler sequences, XYZ for Tait-Bryan), decomposed analytically there (with the gimbal branches), and mapped back; every result is verified by recomposition before reporting success.
public static class EulerUtil
- Inheritance
-
EulerUtil
- Inherited Members
Methods
Compose(EulerSequence, double, double, double)
Composes euler angles (degrees) for sequence into
a rotation matrix: R(Third, third)·R(Second, second)·R(First, first),
the same primitive-call shape as the G68.2 parse side.
public static mat4d_t Compose(EulerSequence sequence, double firstDeg, double secondDeg, double thirdDeg)
Parameters
sequenceEulerSequencefirstDegdoublesecondDegdoublethirdDegdouble
Returns
Compose(double, double, double)
Composes ZXZ euler angles (degrees) into a rotation matrix using the same primitive calls as the G68.2 parse side.
public static mat4d_t Compose(double iDeg, double jDeg, double kDeg)
Parameters
Returns
TryDecompose(mat4d_t, EulerSequence, out double, out double, out double, double)
Tries to decompose the rotation part of rotation
into euler angles (degrees) for sequence. Returns
false when the input is not a proper rotation (recomposition
check fails beyond tolerance); the out values are
still the best attempt.
public static bool TryDecompose(mat4d_t rotation, EulerSequence sequence, out double firstDeg, out double secondDeg, out double thirdDeg, double tolerance = 1E-09)
Parameters
rotationmat4d_tSource matrix; only the rotation rows are read.
sequenceEulerSequenceRotation sequence to decompose into.
firstDegdoubleAngle of the first applied rotation, degrees.
secondDegdoubleAngle of the second applied rotation, degrees; in [0, 180] for proper-euler sequences, [-90, 90] for Tait-Bryan sequences.
thirdDegdoubleAngle of the third applied rotation, degrees.
tolerancedoubleMax absolute element error allowed by the recomposition check.
Returns
TryDecompose(mat4d_t, out double, out double, out double, double)
Tries to decompose the rotation part of rotation
into ZXZ euler angles in degrees (the G68.2 standard format
I/J/K). Returns false when the input is not a proper rotation
(recomposition check fails beyond tolerance); the
out values are still the best attempt.
public static bool TryDecompose(mat4d_t rotation, out double iDeg, out double jDeg, out double kDeg, double tolerance = 1E-09)
Parameters
rotationmat4d_tSource matrix; only the rotation rows are read.
iDegdoubleFirst rotation about Z, degrees.
jDegdoubleSecond rotation about (rotated) X, degrees; in [0, 180].
kDegdoubleThird rotation about (rotated) Z, degrees.
tolerancedoubleMax absolute element error allowed by the recomposition check.