Quaternion To Rodrigues — Robotics/Orientation 3D
Robotics/Orientation_3D/Quaternion_To_Rodrigues · 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 Rodrigues
Robotics / Orientation 3D
Converts a scalar-first [4,1] quaternion [w x y z]T into the [3,1] Rodrigues vector of the same rotation – the Gibbs vector r = tan(θ/2)·n̂:
- r = [x/w y/w z/w]T
The identity follows straight from w = cos(θ/2) and (x, y, z) = sin(θ/2)n̂: the ratio is tan(θ/2) times the axis, and it needs neither a square root nor an inverse trigonometric function.
Because it is a ratio, the input need not be a unit quaternion – scaling q leaves the answer unchanged – and q and −q give the same r, which is correct: they are the same rotation.
Ports
- q – the quaternion, a [4,1] column [w x y z]T, scalar-first. The size is fixed: a quaternion is four numbers.
- r – the Rodrigues vector, a [3,1] column. 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 quaternion arrives on a port.
Every backend takes one reciprocal of w and multiplies the three vector components by it. Three independent divisions would be arithmetically equivalent and would round differently.
On the three HDL targets the block is offered as simulation-only: a Q16.16 datapath has no division, so the reciprocal and the three products go through real arithmetic and only the ports quantize. Note also that 1/w grows without bound as the rotation approaches a half turn, which is a bad thing to hand a fixed-point export.
Simulink bridge
Both directions, onto aerolibtransform2/Quaternions to Rodrigues in the
Aerospace Blockset. The block has no configuration, so no parameter pairs cross.
Its name is drawn on two lines, so the real library path carries an embedded
newline between to and Rodrigues; the flattened one-line spelling
resolves to nothing. And the block defines no SampleTime parameter, so the
rate stays on this side and a block configured with an explicit positive rate reports that the
rate did not cross.
The Simulink block uses rows at both ports; this one uses columns, as every vector port in this family does.
Notes
- Algebraic, with no state: the output depends only on the current input.
- Scalar-first (w, x, y, z), Hamilton convention – the same order as Quaternion Multiply, and not the JPL convention.
- The divisor is w, the scalar component, not the modulus and not the squared norm. Those three agree on a unit quaternion with a positive scalar part, which is what most test data is made of; if you are checking this block against another implementation, check it with something that is not unit.
- w vanishes at a half turn. w = cos(θ/2) is zero at 180°, where the Gibbs vector genuinely is infinite, its coordinates having no point there. The six software targets answer infinity or NaN; the three fixed-point targets answer zero, because fixed point has neither. Nothing is logged.
- No normalization. The answer is scale-invariant, so normalizing would cost a square root and a division and change nothing.
- Deliberately no state space – the map is not linear.
Code facts#
| Fact | Value |
|---|---|
| registered type | Robotics/Orientation_3D/Quaternion_To_Rodrigues |
| family | Robotics/Orientation_3D |
| solver environment class | ICoreBlock_0_Robotics_1_Orientation_3D_2_Quaternion_To_Rodrigues |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Robotics/Orientation_3D/Quaternion_To_Rodrigues/ICoreBlock_0_Robotics_1_Orientation_3D_2_Quaternion_To_Rodrigues.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Robotics/Orientation_3D/Quaternion_To_Rodrigues/ICoreBlock_0_Robotics_1_Orientation_3D_2_Quaternion_To_Rodrigues.h |
| default size on canvas | 120 × 70 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::Both |
| Simulink path | aerolibtransform2/Quaternions to\nRodrigues |
| port-count rule | PortsParam::None |
SampleTime parameter | no — the counterpart defines none; the rate stays on the ICore side |
Caveat (shown to the user): the Aerospace Blockset block is a masked subsystem with no dialog parameters, so nothing but the signal crosses. MEASURED 2026-09-10: it divides the vector part by the SCALAR component, and a non-unit quaternion returns the same answer as its normalized form, which is what confirms the divisor rather than the modulus. It uses rows at both ports where this block uses columns, and it defines no SampleTime parameter: an ICore rate set explicitly stays on this side and is reported
Catalog contract: src/ICoreBlocks/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 Rodrigues — a scalar-first [4,1] quaternion to its [3,1] Gibbs vector r = [ x/w, y/w, z/w ]
which is tan(theta/2)*axis, since w = cos(theta/2) and (x, y, z) = sin(theta/2)*axis.
MEASURED against aerolibtransform2/Quaternions to Rodrigues (R2026a, 2026-09-10): on the unit quaternion of r = [0.37 -0.62 0.21] it returns that vector to the last bit, and on the SAME quaternion scaled by 1.7 it returns it again. The second reading is the one that matters: a ratio is scale-invariant, so a rig fed only unit quaternions could not tell this apart from a divide by the modulus.
⚠ THE DIVISOR IS w, AND IT VANISHES AT A HALF TURN. w = cos(theta/2) is zero at 180 degrees, where the Gibbs vector genuinely is infinite. The six software targets answer infinity or NaN there and the three fixed-point ones answer zero, the same split Quaternion Inverse has at the zero quaternion.
⚠ q AND -q GIVE THE SAME r, because all three components are divided by the same w. That is correct - the two quaternions are the same rotation - and it is what a block that first normalized the scalar part to be positive would get wrong on half its inputs.
⚠ ONE RECIPROCAL, NOT THREE DIVISIONS, in every backend.
⚠ SIMULATION-ONLY on the three HDL targets: Q16.16 has no division.
Sample results#
No stimulus produced a sampled output in this rig — Invalid input size at Quaternion To Rodrigues block: ICore Blocks/Home/Quaternion To Rodrigues. 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 b286d2937 · produced by docsSample --out <folder> --blocks Rodrigues_To_Direction_Cosine_Matrix Direction_Cosine_Matrix_To_Rodrigues Rodrigues_To_Quaternion Quaternion_To_Rodrigues Rodrigues_To_Rotation_Angles Rotation_Angles_To_Rodrigues --steps 60
Sample data: docs/generated/samples/Robotics__Orientation_3D__Quaternion_To_Rodrigues.json