Rodrigues To Direction Cosine Matrix — Robotics/Orientation 3D
Robotics/Orientation_3D/Rodrigues_To_Direction_Cosine_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.
Rodrigues To Direction Cosine Matrix
Robotics / Orientation 3D
Converts a [3,1] Rodrigues vector r – also called the Gibbs vector, r = tan(θ/2)·n̂ for a rotation of θ about the unit axis n̂ – into the [3,3] direction cosine matrix D of that rotation. With n = r·r and den = 1 + n:
- Dii = (1 + 2ri² − n) / den
- Dij = 2(rirj ± rk) / den, with k the remaining axis and the lone term positive on (0,1), (1,2) and (2,0), negative on the other three.
D is the passive matrix: it re-expresses a fixed vector in the rotated frame, so vbody = D·vref. That is the transpose of the active matrix Quaternion To Rotation Matrix produces, and the difference is deliberate – the Aerospace convention this block follows uses the passive one.
The formula is a rational parameterization of the rotation group: every real r gives a genuine rotation matrix, with no square root and no trigonometry anywhere.
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.
- D – the direction cosine 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 rotation arrives on a port.
Every backend takes one reciprocal of 1 + n and scales all nine numerators by it. Nine independent divisions would be arithmetically equivalent and would round differently, so the shared reciprocal is part of the contract.
On the three HDL targets the block is offered as simulation-only: a Q16.16 datapath has no division, so the reciprocal and the nine scalings go through real arithmetic and only the ports quantize. This is the same choice Quaternion Inverse and Recursive IIR make.
Simulink bridge
Both directions, onto
aerolibtransform2/Rodrigues to Direction Cosine Matrix 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 Direction; the flattened one-line spelling
resolves to nothing, silently. 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 accepts the Rodrigues vector as a row; this one takes a column, as every vector port in this family does.
Notes
- Algebraic, with no state: the output depends only on the current input.
- The denominator cannot vanish. 1 + r·r ≥ 1 for every real r, so this direction has no pole. The inverse direction does – see Direction Cosine Matrix To Rodrigues, whose denominator is 1 + trace(D).
- The result is the PASSIVE matrix, the transpose of what Quaternion To Rotation Matrix returns. Chaining the two without a transpose rotates by twice the angle.
- Deliberately no state space – the map is a rational function of the input, so there is no linear form to fabricate.
Code facts#
| Fact | Value |
|---|---|
| registered type | Robotics/Orientation_3D/Rodrigues_To_Direction_Cosine_Matrix |
| family | Robotics/Orientation_3D |
| solver environment class | ICoreBlock_0_Robotics_1_Orientation_3D_2_Rodrigues_To_Direction_Cosine_Matrix |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Robotics/Orientation_3D/Rodrigues_To_Direction_Cosine_Matrix/ICoreBlock_0_Robotics_1_Orientation_3D_2_Rodrigues_To_Direction_Cosine_Matrix.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Robotics/Orientation_3D/Rodrigues_To_Direction_Cosine_Matrix/ICoreBlock_0_Robotics_1_Orientation_3D_2_Rodrigues_To_Direction_Cosine_Matrix.h |
| default size on canvas | 140 × 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 | r |
| 2 | out | ICoreDouble | D |
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\nDirection Cosine Matrix |
| 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 the closed rational form, and the matrix is the PASSIVE one (the transpose of the active rotation matrix). It takes the Rodrigues vector as a row where this block takes a column, 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 Direction Cosine Matrix — a [3,1] Gibbs vector to its [3,3] passive DCM r = tan(theta/2) * axis, n = r.r, den = 1 + n
D(i,i) = (1 + 2*r(i)^2 - n) / den D(i,j) = 2*(r(i)*r(j) + s*r(k)) / den, s = +1 on (0,1), (1,2), (2,0); -1 on the rest
MEASURED against aerolibtransform2/Rodrigues to Direction Cosine Matrix (R2026a, 2026-09-10): r = [0.37 -0.62 0.21] answers [ 0.4525 -0.0248 0.8914 ] [-0.5614 0.7687 0.3064 ] [-0.6929 -0.6391 0.3340 ] which is the closed form above to the last bit, and is the TRANSPOSE of the active rotation matrix of the same rotation.
⚠ THE SIGN OF THE LONE r(k) TERM IS CYCLIC, NOT TRIANGULAR — positive exactly when the column is the cyclic successor of the row. It is written ONCE, in coeffAt() below, and the C++ reference and all ten generators read it from there. A per-target transcription of nine formulas is exactly the kind of thing that goes wrong in one target and nowhere else.
⚠ NINE SCALINGS, ONE RECIPROCAL, in every backend. Nine independent divisions are arithmetically equivalent and round differently, so the shared reciprocal is part of the contract rather than an optimisation.
⚠ 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 Rodrigues To Direction Cosine Matrix block: ICore Blocks/Home/Rodrigues To Direction Cosine 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 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_Direction_Cosine_Matrix.json