Deviation from Identity Matrix#

ahrs.utils.metrics.identity_deviation(R1: ndarray, R2: ndarray) float#

The deviation from the identity matrix between two rotations \(\mathbf{R}_1\) and \(\mathbf{R}_2\) in SO(3) is defined in [Huy09] as:

\[d(\mathbf{R}_1, \mathbf{R}_2) = \|\mathbf{I}-\mathbf{R}_1\mathbf{R}_2^T\|_F\]

where \(\|\mathbf{X}\|_F\) represents the Frobenius norm of the matrix \(\mathbf{X}\).

If the given matrices are close to each other, the resulting deviation will be close to zero.

The error lies within: [0, \(2\sqrt{3}\)]

Parameters:
  • R1 (numpy.ndarray) – 3-by-3 rotation matrix.

  • R2 (numpy.ndarray) – 3-by-3 rotation matrix.

Returns:

d – Deviation from identity matrix.

Return type:

float

Raises:
  • ValueError – If the rotation matrices are not of the same shape.

  • TypeError – If the rotation matrices are not of type list or numpy.ndarray.

Examples

>>> import ahrs
>>> R1 = ahrs.DCM(rpy=[0.0, 0.0, 0.0])
>>> R2 = ahrs.DCM(rpy=[90.0, 90.0, 90.0])
>>> ahrs.utils.identity_deviation(R1, R2)
2.0
>>> R1 = ahrs.DCM(rpy=[10.0, -20.0, 30.0])
>>> R2 = ahrs.DCM(rpy=[-10.0, 20.0, -30.0])
>>> ahrs.utils.identity_deviation(R1, R2)
1.6916338074634352