Quaternion To Rotation Matrix — Robotics/Orientation 3D
Robotics/Orientation_3D/Quaternion_To_Rotation_Matrix · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text
Description#
The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.
Quaternion To Rotation Matrix
Robotics / Orientation 3D
Converts a scalar-first [4,1] quaternion [w x y z]T into the [3,3] rotation matrix it represents:
- R00 = 1 − 2(y² + z²), R01 = 2(xy − wz), R02 = 2(xz + wy)
- R10 = 2(xy + wz), R11 = 1 − 2(x² + z²), R12 = 2(yz − wx)
- R20 = 2(xz − wy), R21 = 2(yz + wx), R22 = 1 − 2(x² + y²)
The rotation is active and right-handed: R rotates a vector within a fixed frame, so a 90° rotation about +z sends x̂ to ŷ. Feed it to Matrix Multiply to chain frames, or transpose it for the inverse rotation – for a unit quaternion RT = R−1.
Ports
- q – the quaternion, a [4,1] column [w x y z]T.
- R – the rotation matrix, [3,3]. Its size is fixed and does not follow the input's.
Parameters
- Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.
Code export
All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. There is no tunable parameter, because the block has no parameter at all.
The three HDL targets are genuinely synthesizable Q16.16: the nine entries are products and sums, with no division, square root or trigonometry anywhere.
Simulink bridge
None, measured rather than assumed: quaternion blocks ship in the Aerospace Blockset and the Robotics System Toolbox, neither of which is installed on this machine. A model carrying this block exports with the block reported rather than silently dropped.
Notes
- Algebraic and stateless.
- Scalar-first (w, x, y, z), Hamilton convention – the same order and sign as Quaternion Multiply, and not the JPL convention.
- The quaternion is assumed to be a UNIT quaternion, and the block does not normalize it. R is the rotation matrix of q only when |q| = 1; for any other q the formula above is still exactly what the block computes, which is what keeps every target – including the fixed-point ones – free of a square root and a division. Normalize upstream with Normalizer (L2 mode) when the source cannot guarantee it.
- Quadratic in the input, so deliberately no state space – a fabricated linear form would let model reduction merge matrices that do not describe this block.
- The w-term signs follow the CYCLIC order, negative on (0,1), (1,2) and (2,0) and positive on the other three. It is not a triangular pattern, and the two entries where those readings disagree are exactly the ones that break RTR = I.
Code facts#
| Fact | Value |
|---|---|
| registered type | Robotics/Orientation_3D/Quaternion_To_Rotation_Matrix |
| family | Robotics/Orientation_3D |
| solver environment class | ICoreBlock_0_Robotics_1_Orientation_3D_2_Quaternion_To_Rotation_Matrix |
| source | src/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Orientation_3D/Quaternion_To_Rotation_Matrix/ICoreBlock_0_Robotics_1_Orientation_3D_2_Quaternion_To_Rotation_Matrix.cpp |
| header | src/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Orientation_3D/Quaternion_To_Rotation_Matrix/ICoreBlock_0_Robotics_1_Orientation_3D_2_Quaternion_To_Rotation_Matrix.h |
| default size on canvas | 126 × 84 px |
| ports at insert | 1 in, 1 out |
| code generators implemented | Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text |
Ports#
| # | Direction | Signal type | Description label |
|---|---|---|---|
| 1 | in | ICoreDouble | q |
| 2 | out | ICoreDouble | R |
Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.
Configuration variables#
No config variable beyond the Sampling Time (s) every block carries.
Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.
Simulink bridge#
| support | Support::None |
| Simulink path | — |
| port-count rule | PortsParam::None |
SampleTime parameter | yes |
Caveat (shown to the user): no Simulink equivalent available: the quaternion-to-DCM blocks ship in the Aerospace Blockset and the Robotics System Toolbox, neither of which is installed. Rebuild the nine entries on the Simulink side from Product and Sum blocks, keeping the scalar-first (w, x, y, z) Hamilton convention and the active sense this block uses
Catalog contract: src/ICoreSDK/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h
Description vs code#
The checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:
B0every stimulus in the sample errored — cross-checks skipped
The verdict above is
tools/docs/check_block_descriptions.py(P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.
File banner (developer view)#
The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).
Quaternion To Rotation Matrix — [4,1] scalar-first quaternion to its [3,3] rotation R = | 1-2(y^2+z^2) 2(xy - wz) 2(xz + wy) | | 2(xy + wz) 1-2(x^2+z^2) 2(yz - wx) | | 2(xz - wy) 2(yz + wx) 1-2(x^2+y^2) |
Multiply-add only, so all ten targets are exact and the three HDL ones are genuinely synthesizable Q16.16 rather than simulation-only real. See the header for the two decisions (no normalization; the cyclic sign rule).
⚠ THE NINE ENTRIES ARE WRITTEN ONCE, in coeffAt() below, and the C++ reference and all ten generators consume it. Two of the six off-diagonal signs are not what a triangular reading of the matrix suggests, so a per-backend transcription of the nine formulas is exactly the kind of thing that goes wrong in one target and nowhere else.
Sample results#
No stimulus produced a sampled output in this rig — Invalid input size at Quaternion To Rotation Matrix block: ICore Blocks/Home/Quaternion To Rotation Matrix. That is a fact about the single-block rig, not a verdict on the block: an offline batch fit, a block whose output only appears at onSolverFinish, or one that needs a driven environment cannot be exercised alone.
Category unsampled · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60
Sample data: docs/generated/samples/Robotics__Orientation_3D__Quaternion_To_Rotation_Matrix.json