function
Tests.RuleChecks.fdSo3LogMapJacobian
Central difference of SO(3) log_map, right-trivialized input
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| input | q | Real | [4] | Unit quaternion |
| input | step | Real | | Central-difference step |
| output | J | Real | [3, 3] |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function fdSo3LogMapJacobian
"Central difference of SO(3) log_map, right-trivialized input"
input Real q[4] "Unit quaternion";
input Real step "Central-difference step";
output Real J[3, 3];
protected
Real basis[3, 3];
Real forward[3];
Real backward[3];
algorithm
basis := identity(3);
for j in 1:3 loop
forward := LieGroups.SO3.Quat.log_map(LieGroups.SO3.Quat.product(
q, LieGroups.SO3.Quat.exp_map(step * basis[:, j])));
backward := LieGroups.SO3.Quat.log_map(LieGroups.SO3.Quat.product(
q, LieGroups.SO3.Quat.exp_map(-step * basis[:, j])));
J[:, j] := (forward - backward) / (2.0 * step);
end for;
end fdSo3LogMapJacobian;