Rodrigues To Quaternion — Robotics/Orientation 3D
Robotics/Orientation_3D/Rodrigues_To_Quaternion · 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.
Rodrigues To Quaternion
Robotics / Orientation 3D
Converts a [3,1] Rodrigues vector r – the Gibbs vector r = tan(θ/2)·n̂ – into the scalar-first [4,1] unit quaternion [w x y z]T of the same rotation:
- s = √(1 + r·r)
- q = [1/s r0/s r1/s r2/s]T
Because 1/s = cos(θ/2) and ri/s = sin(θ/2)n̂i, the output is always a unit quaternion and its scalar part is always non-negative – the Rodrigues coordinates cannot express the other half of the quaternion double cover, and both halves name the same rotation anyway.
Ports
- r – the Rodrigues vector, a [3,1] column. The size is fixed: three numbers. r = 0 is the identity rotation, and |r| grows without bound as the rotation approaches a half turn.
- q – the quaternion, a [4,1] column [w x y z]T. 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 rotation arrives on a port.
Every backend takes one reciprocal of s and multiplies the four components by it. Four 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 neither a square root nor a division, so both go through real arithmetic and only the ports quantize. This is the same choice Quaternion Modulus and Quaternion Inverse make.
Simulink bridge
Both directions, onto aerolibtransform2/Rodrigues to Quaternions 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 Quaternions; 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 takes the Rodrigues vector as a row and returns the quaternion as a row; this one uses columns at both ports, 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 and sign as Quaternion Multiply, and not the JPL convention.
- No guard anywhere. 1 + r·r ≥ 1, so the root is always real and the reciprocal always finite. That is unusual in this family, and it is why this block has no branch and no zero case.
- The output is always unit and its scalar part is always non-negative. Round-tripping through Quaternion To Rodrigues returns the input; round-tripping the other way returns ±q, which is the same rotation.
- Deliberately no state space – the map is not linear.
Code facts#
| Fact | Value |
|---|---|
| registered type | Robotics/Orientation_3D/Rodrigues_To_Quaternion |
| family | Robotics/Orientation_3D |
| solver environment class | ICoreBlock_0_Robotics_1_Orientation_3D_2_Rodrigues_To_Quaternion |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Robotics/Orientation_3D/Rodrigues_To_Quaternion/ICoreBlock_0_Robotics_1_Orientation_3D_2_Rodrigues_To_Quaternion.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Robotics/Orientation_3D/Rodrigues_To_Quaternion/ICoreBlock_0_Robotics_1_Orientation_3D_2_Rodrigues_To_Quaternion.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 | r |
| 2 | out | ICoreDouble | q |
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/Rodrigues to\nQuaternions |
| 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 answers [1, r] / sqrt(1 + r.r) to the last bit, scalar-first. 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).
Rodrigues To Quaternion — a [3,1] Gibbs vector to the scalar-first [4,1] unit quaternion s = sqrt(1 + r.r) q = [ 1/s, r(0)/s, r(1)/s, r(2)/s ]
With r = tan(theta/2)*axis that is exactly [cos(theta/2), sin(theta/2)*axis], so the result is always a unit quaternion whose scalar component is NON-NEGATIVE.
MEASURED against aerolibtransform2/Rodrigues to Quaternions (R2026a, 2026-09-10): r = [0.37 -0.62 0.21] answers [0.79925863182503387 0.29572569377526259 -0.49554035173152106 0.16784431268325714] which is the closed form above to the last bit.
⚠ ONE RECIPROCAL, NOT FOUR DIVISIONS, in every backend. Four independent divisions are arithmetically equivalent and round differently, so the shared reciprocal is part of the contract rather than an optimisation.
⚠ NO GUARD IS NEEDED ANYWHERE: 1 + r.r >= 1, so the root is always real and the reciprocal always finite. That is unusual in this family and is why this body has no branch.
⚠ SIMULATION-ONLY on the three HDL targets: a square root and a division.
Sample results#
No stimulus produced a sampled output in this rig — Invalid input size at Rodrigues To Quaternion block: ICore Blocks/Home/Rodrigues To Quaternion. 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__Rodrigues_To_Quaternion.json