Numerical checks
Conversion preserves orientation within the precision of the input and numerical representation. Check data validity, conventions, rounding, and Euler singularities.
Component order and input parsing
Quaternion input and MATLAB output use scalar-last order . Eigen and Python constructors place first. The Quaternion (, , , ) heading stays fixed; read copied constructor values in argument order.
Bulk Import extracts numeric tokens, including scientific notation, in their written order. Enter a bare numeric array and evaluate expressions first: 1/2 supplies and ; 0.5 supplies their quotient. Digits in comments or type names such as Matrix3d also count as values.
Python output provides constructor syntax. Add the required imports and check the receiving library’s matrix and quaternion conventions for every target language.
| Interface | Order |
|---|---|
| Interactive or bulk quaternion input | , , , |
| MATLAB quaternion output | |
| Eigen quaternion output | Eigen::Quaterniond q(w, x, y, z) |
| Python quaternion output | quaternion.Quaternion(w, x, y, z) |
Angle units and displayed precision
Input and output angle units are independent. Degrees or radians apply to Euler angles and the axis-angle angle. Matrix, quaternion, and axis components are dimensionless. A quarter-turn is radians.
Changing input units rescales interactive Euler and axis-angle fields, including individual sequence entries. Pasted numbers remain unchanged and use the selected units on the next parse. Set units before pasting or verify the numbers afterward.
Output units control Euler and axis-angle formatting, including the Eigen constructor. Select Radians when copying Eigen::AngleAxisd, which requires radians.
Decimal Places sets copied values to 1–16 places; the default is 4 and worked examples use 6. The stored matrix retains its precision. Re-entered rounded text has the copied precision. Matrix Determinant uses six decimals; the orthogonality residual uses scientific notation.
Quaternion normalization and equivalence
Normalize nonzero input as . For example, has norm . Its normalized form represents a quarter-turn about . Evaluate the square roots numerically before entry.
Manual quaternion-to-matrix conversion uses supplied components. Matrix-to-quaternion conversion normalizes its result; verify source-matrix orthogonality separately. ROS Bag normalizes quaternions for replay and reports materially nonunit inputs in Import notes.
For unit quaternions, identifies the same rotation, including the sign pair , . Compare with a tolerance suited to the source precision, or compare reconstructed matrices under the same convention. Source precision limits meaningful output digits.
Matrix determinant and orthogonality
A proper rotation satisfies both and . The shear matrix below has determinant and nonorthogonal first and second rows.
The residual is the largest absolute entry of , using stored matrix . It triggers a warning above . The determinant warning requires . Transposition preserves determinants. For invalid matrices, entrywise residuals of and may differ; the display always uses stored .
Conversion rejects non-finite matrix entries. Finite invalid matrices are used directly and may produce output and warnings. A zero axis produces non-finite entries and is rejected. Enter identity with a nonzero axis and zero angle.
After a failed check, inspect quaternion norm, source precision, component order, scale, and shear. A reflection has determinant and reverses orientation. Confirm the intended frame mapping from the source conventions.
Euler singularities and the extraction branch
Every supported sequence is singular at middle angle . The first and third rotations are coupled, so many outer-angle pairs represent one orientation. Matrix and quaternion representations remain valid.
The solver obtains from a sequence-dependent matrix entry. The regular branch computes with , using and a nonnegative square-root denominator from two other entries. Its range is to . Sequence-specific expressions give the outer angles.
The regular branch requires . Otherwise, the solver sets , sets with the sign of , and computes the remaining angle from the table below. For valid matrices, this threshold is approximately .
Near singularity appears when the extracted middle angle lies strictly within of . This warning also covers regular-branch values. In Active mode, both rules apply to the reversed extraction sequence.
For input degrees, matrix and quaternion retain ; Euler extraction returns . Reconstruction from that triple changes the largest matrix entry by about . Use the matrix or quaternion when this difference matters. Worked example 3 derives it.
| Sequence | when | |
|---|---|---|
| / | ||
| / | ||
| / | ||
| / | ||
| / | ||
| / |