Skip to content

Commit

Permalink
Explain orthonormalization
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderFabisch committed Sep 28, 2023
1 parent ec9372d commit 76de9ba
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/source/rotations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ A more compact representation of these constraints is
\Leftrightarrow \boldsymbol R^T = \boldsymbol R^{-1}`.

In addition, :math:`\det(\boldsymbol R) = 1` because we use right-handed
coordinate system (:math:`\det(\boldsymbol R) = -1` for left-handed
coordinate system (:math:`\det(\boldsymbol R) = -1` for left-handed
coordinate systems).

Hence, the group :math:`SO(3)` is defined as
Expand Down
37 changes: 34 additions & 3 deletions pytransform3d/rotations/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,44 @@ def norm_vector(v):


def norm_matrix(R):
"""Orthonormalize rotation matrix.
r"""Orthonormalize rotation matrix.
A rotation matrix is defined as
.. math::
\boldsymbol R =
\left( \begin{array}{ccc}
r_{11} & r_{12} & r_{13}\\
r_{21} & r_{22} & r_{23}\\
r_{31} & r_{32} & r_{33}\\
\end{array} \right)
\in SO(3)
and must be orthonormal, which results in 6 constraints:
* column vectors must have unit norm (3 constraints)
* and must be orthogonal to each other (3 constraints)
A more compact representation of these constraints is
:math:`\boldsymbol R^T \boldsymbol R = \boldsymbol I`.
Because of numerical problems, a rotation matrix might not satisfy the
constraints anymore. This function will enforce them.
Parameters
----------
R : array-like, shape (3, 3)
Rotation matrix with small numerical errors
Rotation matrix with small numerical errors.
Returns
-------
R : array, shape (3, 3)
Normalized rotation matrix
Orthonormalized rotation matrix.
See Also
--------
check_matrix : Checks orthonormality of a rotation matrix.
"""
R = np.asarray(R)
c2 = R[:, 1]
Expand Down Expand Up @@ -431,6 +458,10 @@ def check_matrix(R, tolerance=1e-6, strict_check=True):
------
ValueError
If input is invalid
See Also
--------
norm_matrix : Enforces orthonormality of a rotation matrix.
"""
R = np.asarray(R, dtype=np.float64)
if R.ndim != 2 or R.shape[0] != 3 or R.shape[1] != 3:
Expand Down

0 comments on commit 76de9ba

Please sign in to comment.