Chordal Distance#
- ahrs.utils.metrics.chordal(R1: ndarray, R2: ndarray) float | ndarray#
The chordal distance between two rotations \(\mathbf{R}_1\) and \(\mathbf{R}_2\) in SO(3) is the Euclidean distance between them in the embedding space \(\mathbb{R}^{3\times 3}=\mathbb{R}^9\) [HTDL13]:
\[d(\mathbf{R}_1, \mathbf{R}_2) = \|\mathbf{R}_1-\mathbf{R}_2\|_F\]where \(\|\mathbf{X}\|_F\) represents the Frobenius norm of the matrix \(\mathbf{X}\).
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 – Chordal distance between matrices.
- Return type:
float or numpy.ndarray
- 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.chordal(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.chordal(R1, R2) 1.6916338074634352