The orthogonal group
LieGroups.OrthogonalGroup
— TypeOrthogonalGroup{T}
The orthogonal group $\mathrm{O}(n)$ is the Lie group consisting of the MatrixMultiplicationGroupOperation
on the manifold of rotations OrthogonalMatrices
.
Constructor
OrthogonalGroup(n::Int; kwargs...)
Generate orthogonal group $\mathrm{O}(n)$. All keyword arguments in kwargs...
are passed on to OrthogonalMatrices
as well.
For this Lie group, several implementations are already covered by the defaults in the generic (matrix) multiplication operation.
Functions
Base.exp
— Methodexp(G, X)
exp!(G, g, X)
Compute the Lie group exponential function on the OrthogonalGroup
$\mathrm{O}(2)$ or SpecialOrthogonalGroup
$\mathrm{SO}(2)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
Since the Lie algebra of both groups agrees and consist of the set of skew symmetric matrices, these simplify for the case of $2×2$ matrices to $X=\begin{pmatrix} 0 & -α\\ α & 0\end{pmatrix}$, for some $α∈ℝ$.
Their exponential is
\[\exp_{\mathcal G}(X) = \begin{pmatrix} \cos(α) & -\sin(α)\\ \sin(α) & \cos(α)\end{pmatrix}.\]
This result can be computed in-place of g
.
Note that since $\mathrm{O}(2)$ consists of two disjoint connected components and the exponential map is smooth, the result $g$ always lies in the connected component of the identity.
Base.exp
— Methodexp(G, X)
exp!(G, g, X)
Compute the Lie group exponential function on the OrthogonalGroup
$\mathrm{O}(3)$ or SpecialOrthogonalGroup
$\mathrm{SO}(3)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
Since the Lie algebra of both groups agrees and consist of the set of skew symmetric matrices, the $3×3$ skew symmetric matrices are of the form
\[ X = \begin{pmatrix} 0 & -c & b\\ c & 0 & -a\\ -b & a & 0\end{pmatrix},\]
for some $a, b, c ∈ ℝ$. To compute the exponential, the Rodrigues' rotation formula can be used. With $α = \sqrt{a^2+b^2+c^2} = \frac{1}{\sqrt{2}}\lVert X \rVert_{}$ we obtain for $α ≠ 0$
\[\exp_{\mathcal G}(X) = I_3 + \frac{\sin}{α}X + \frac{(1 - \cos)}{α^2}X^2,\]
and \exp{\mathcal G}(X) = I3`` otherwise.
This result can be computed in-place of g
.
Note that since $\mathrm{SO}(3)$ consists of two disjoint connected components and the exponential map is smooth, the result $g$ always lies in the connected component of the identity.
Base.exp
— Methodexp(G, e, X)
exp!(G, e, g, X)
Compute the Lie group exponential function on the OrthogonalGroup
$\mathrm{O}(4)$ or SpecialOrthogonalGroup
$\mathrm{SO}(4)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
Similar to the $3×3$ case, an efficient computation is provided, adapted from [GX02], [AR13] with a few numerical stabilisations.
Base.log
— Methodlog(G, g)
log!(G, X, g)
Compute the Lie group logarithm function on the OrthogonalGroup
$\mathrm{O}(2)$ or SpecialOrthogonalGroup
$\mathrm{SO}(2)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
For the two-dimensional case, any rotation matrix $g$ can be represented as $\begin{pmatrix} \cos(α) & -\sin(α)\\ \sin(α) & \cos(α)\end{pmatrix}$. For the SpecialOrthogonalGroup
, $g$ might also include reflections.
The logarithm is then
\[\log_{\mathcal G}(g) = \begin{pmatrix} 0 & α\\ -α & 0\end{pmatrix}.\]
This result can be computed in-place of X
Note the logarithmic map is only locally around the identity uniquely determined. Especially, since $\mathrm{O}(2)$ consists of two disjoint connected components and the exponential map is smooth, for any $g$ in the other component, the logarithmic map is defined, but not the inverse of the exponential map.
Base.log
— Methodlog(G, g)
log!(G, X, g)
Compute the Lie group logarithm function on the OrthogonalGroup
$\mathrm{O}(3)$ or SpecialOrthogonalGroup
$\mathrm{SO}(3)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
Here, $\exp_{\mathcal G}(X) = g$ is inverted using the Rodrigues' rotation formula
\[\exp_{\mathcal G}(X) = I_3 + \frac{\sin}{α}X + \frac{(1 - \cos)}{α^2}X^2,\]
For $α ∉ \{ 0, π \}$ we obtain $X$ from the observation that
\[\mathrm{tr}(g) = 1 + 2\cos(α) \qquad\text{ and }\qquad \frac{1}{2}(g-g^\mathrm{T}) = \sin(α)X.\]
For $α = 0$ we have $g = I_3$ and $X = 0$.
For $α = π$ we have to solve $X^2 = \frac{1}{2}(g-I_3)$, where $X$ is skew-symmetric and hence we have to solve for three unknowns.
\[\log_{\mathcal G}(g) = X.\]
This result can be computed in-place of X
Note the logarithmic map is only locally around the identity uniquely determined. Especially, since $\mathrm{O}(3)$ consists of two disjoint connected components and the exponential map is smooth, for any $g$ in the other component, the logarithmic map is defined, but not the inverse of the exponential map.
Base.log
— Methodlog(G, g)
log!(G, X, g)
Compute the Lie group logarithm function on the OrthogonalGroup
$\mathrm{O}(4)$ or SpecialOrthogonalGroup
$\mathrm{SO}(4)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
The implementation is based on a generalized variant of the Rodrigues' like formula. For details, see [GX02, Section 3].
This result can be computed in-place of X
Note the logarithmic map is only locally around the identity uniquely determined.
ManifoldsBase.exp!
— Methodexp(G, X)
exp!(G, g, X)
Compute the Lie group exponential function on the OrthogonalGroup
$\mathrm{O}(2)$ or SpecialOrthogonalGroup
$\mathrm{SO}(2)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
Since the Lie algebra of both groups agrees and consist of the set of skew symmetric matrices, these simplify for the case of $2×2$ matrices to $X=\begin{pmatrix} 0 & -α\\ α & 0\end{pmatrix}$, for some $α∈ℝ$.
Their exponential is
\[\exp_{\mathcal G}(X) = \begin{pmatrix} \cos(α) & -\sin(α)\\ \sin(α) & \cos(α)\end{pmatrix}.\]
This result can be computed in-place of g
.
Note that since $\mathrm{O}(2)$ consists of two disjoint connected components and the exponential map is smooth, the result $g$ always lies in the connected component of the identity.
ManifoldsBase.exp!
— Methodexp(G, X)
exp!(G, g, X)
Compute the Lie group exponential function on the OrthogonalGroup
$\mathrm{O}(3)$ or SpecialOrthogonalGroup
$\mathrm{SO}(3)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
Since the Lie algebra of both groups agrees and consist of the set of skew symmetric matrices, the $3×3$ skew symmetric matrices are of the form
\[ X = \begin{pmatrix} 0 & -c & b\\ c & 0 & -a\\ -b & a & 0\end{pmatrix},\]
for some $a, b, c ∈ ℝ$. To compute the exponential, the Rodrigues' rotation formula can be used. With $α = \sqrt{a^2+b^2+c^2} = \frac{1}{\sqrt{2}}\lVert X \rVert_{}$ we obtain for $α ≠ 0$
\[\exp_{\mathcal G}(X) = I_3 + \frac{\sin}{α}X + \frac{(1 - \cos)}{α^2}X^2,\]
and \exp{\mathcal G}(X) = I3`` otherwise.
This result can be computed in-place of g
.
Note that since $\mathrm{SO}(3)$ consists of two disjoint connected components and the exponential map is smooth, the result $g$ always lies in the connected component of the identity.
ManifoldsBase.exp!
— Methodexp(G, e, X)
exp!(G, e, g, X)
Compute the Lie group exponential function on the OrthogonalGroup
$\mathrm{O}(4)$ or SpecialOrthogonalGroup
$\mathrm{SO}(4)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
Similar to the $3×3$ case, an efficient computation is provided, adapted from [GX02], [AR13] with a few numerical stabilisations.
ManifoldsBase.get_coordinates!
— Methodget_coordinates(𝔤::OrthogonalLieAlgebra, X, ::DefaultLieAlgebraOrthogonalBasis)
get_coordinates(G::SpecialOrthogonalLieAlgebra, X, ::DefaultLieAlgebraOrthogonalBasis)
get_coordinates!(G::OrthogonalLieAlgebra, c, X ::DefaultLieAlgebraOrthogonalBasis)
get_coordinates!(G::SpecialOrthogonalLieAlgebra, c, X ::DefaultLieAlgebraOrthogonalBasis)
Compute the vector of coordinates $c ∈ ℝ^d$ from the Lie algebra tangent vector $X ∈ 𝔬(n)$ of the OrthogonalGroup
O(n)
in the DefaultLieAlgebraOrthogonalBasis
, where $d$ is the dimension of the Lie algebra. This is also the version used in vee
.
For $O(2)$ there is only one coefficient $α$ in the basis $\begin{pmatrix} 0 & -α\\ α & 0\end{pmatrix}$, which is returned as $c = (α)^\mathrm{T}$.
A usual basis representation of ``𝔬(3) is given by
\[ X = \begin{pmatrix} 0 & -γ & β\\ γ & 0 & -α\\ -β & α & 0\end{pmatrix},\]
hence the coordinate vector is $c = (α, β, γ)^\mathrm{T} ∈ ℝ^3$.
For n ≥ 4
the lower triangular part is added to
c
` row-wise.
ManifoldsBase.get_coordinates
— Methodget_coordinates(𝔤::OrthogonalLieAlgebra, X, ::DefaultLieAlgebraOrthogonalBasis)
get_coordinates(G::SpecialOrthogonalLieAlgebra, X, ::DefaultLieAlgebraOrthogonalBasis)
get_coordinates!(G::OrthogonalLieAlgebra, c, X ::DefaultLieAlgebraOrthogonalBasis)
get_coordinates!(G::SpecialOrthogonalLieAlgebra, c, X ::DefaultLieAlgebraOrthogonalBasis)
Compute the vector of coordinates $c ∈ ℝ^d$ from the Lie algebra tangent vector $X ∈ 𝔬(n)$ of the OrthogonalGroup
O(n)
in the DefaultLieAlgebraOrthogonalBasis
, where $d$ is the dimension of the Lie algebra. This is also the version used in vee
.
For $O(2)$ there is only one coefficient $α$ in the basis $\begin{pmatrix} 0 & -α\\ α & 0\end{pmatrix}$, which is returned as $c = (α)^\mathrm{T}$.
A usual basis representation of ``𝔬(3) is given by
\[ X = \begin{pmatrix} 0 & -γ & β\\ γ & 0 & -α\\ -β & α & 0\end{pmatrix},\]
hence the coordinate vector is $c = (α, β, γ)^\mathrm{T} ∈ ℝ^3$.
For n ≥ 4
the lower triangular part is added to
c
` row-wise.
ManifoldsBase.get_vector!
— Methodget_vector(G::OrthogonalLieAlgebra, e, c, ::DefaultLieAlgebraOrthogonalBasis)
get_vector(G::SpecialOrthogonalLieAlgebra, e, c, ::DefaultLieAlgebraOrthogonalBasis)
get_vector!(G::OrthogonalLieAlgebra, X, e, c, ::DefaultLieAlgebraOrthogonalBasis)
get_vector!(G::SpecialOrthogonalLieAlgebra, X, e, c, ::DefaultLieAlgebraOrthogonalBasis)
Compute the tangent vector $X ∈ 𝔬(n)$ based on a vector of coordinates $c ∈ ℝ^d$, where $d$ is the dimension of the Lie algebra of the OrthogonalGroup
O(n)
and the coordinates are with respect to the DefaultLieAlgebraOrthogonalBasis
. This is also the version used in hat
.
For $O(2)$ there is only one coefficient ``$c = (α)^\mathrm{T}$ and hence $X = \begin{pmatrix} 0 & -α\\ α & 0\end{pmatrix}$ is returned.
For $n=3$ a usual representtion turns $c = (α, β, γ)^\mathrm{T} ∈ ℝ^3$ into
\[ X = \begin{pmatrix} 0 & -γ & β\\ γ & 0 & -α\\ -β & α & 0\end{pmatrix},\]
hence the coordinate vector is .
For n ≥ 4
` all further coefficients are used to fill up the following rows of the lower triangular part – which determines the upper triangular part due to skew-symmetry
ManifoldsBase.get_vector
— Methodget_vector(G::OrthogonalLieAlgebra, e, c, ::DefaultLieAlgebraOrthogonalBasis)
get_vector(G::SpecialOrthogonalLieAlgebra, e, c, ::DefaultLieAlgebraOrthogonalBasis)
get_vector!(G::OrthogonalLieAlgebra, X, e, c, ::DefaultLieAlgebraOrthogonalBasis)
get_vector!(G::SpecialOrthogonalLieAlgebra, X, e, c, ::DefaultLieAlgebraOrthogonalBasis)
Compute the tangent vector $X ∈ 𝔬(n)$ based on a vector of coordinates $c ∈ ℝ^d$, where $d$ is the dimension of the Lie algebra of the OrthogonalGroup
O(n)
and the coordinates are with respect to the DefaultLieAlgebraOrthogonalBasis
. This is also the version used in hat
.
For $O(2)$ there is only one coefficient ``$c = (α)^\mathrm{T}$ and hence $X = \begin{pmatrix} 0 & -α\\ α & 0\end{pmatrix}$ is returned.
For $n=3$ a usual representtion turns $c = (α, β, γ)^\mathrm{T} ∈ ℝ^3$ into
\[ X = \begin{pmatrix} 0 & -γ & β\\ γ & 0 & -α\\ -β & α & 0\end{pmatrix},\]
hence the coordinate vector is .
For n ≥ 4
` all further coefficients are used to fill up the following rows of the lower triangular part – which determines the upper triangular part due to skew-symmetry
ManifoldsBase.log!
— Methodlog(G, g)
log!(G, X, g)
Compute the Lie group logarithm function on the OrthogonalGroup
$\mathrm{O}(2)$ or SpecialOrthogonalGroup
$\mathrm{SO}(2)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
For the two-dimensional case, any rotation matrix $g$ can be represented as $\begin{pmatrix} \cos(α) & -\sin(α)\\ \sin(α) & \cos(α)\end{pmatrix}$. For the SpecialOrthogonalGroup
, $g$ might also include reflections.
The logarithm is then
\[\log_{\mathcal G}(g) = \begin{pmatrix} 0 & α\\ -α & 0\end{pmatrix}.\]
This result can be computed in-place of X
Note the logarithmic map is only locally around the identity uniquely determined. Especially, since $\mathrm{O}(2)$ consists of two disjoint connected components and the exponential map is smooth, for any $g$ in the other component, the logarithmic map is defined, but not the inverse of the exponential map.
ManifoldsBase.log!
— Methodlog(G, g)
log!(G, X, g)
Compute the Lie group logarithm function on the OrthogonalGroup
$\mathrm{O}(3)$ or SpecialOrthogonalGroup
$\mathrm{SO}(3)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
Here, $\exp_{\mathcal G}(X) = g$ is inverted using the Rodrigues' rotation formula
\[\exp_{\mathcal G}(X) = I_3 + \frac{\sin}{α}X + \frac{(1 - \cos)}{α^2}X^2,\]
For $α ∉ \{ 0, π \}$ we obtain $X$ from the observation that
\[\mathrm{tr}(g) = 1 + 2\cos(α) \qquad\text{ and }\qquad \frac{1}{2}(g-g^\mathrm{T}) = \sin(α)X.\]
For $α = 0$ we have $g = I_3$ and $X = 0$.
For $α = π$ we have to solve $X^2 = \frac{1}{2}(g-I_3)$, where $X$ is skew-symmetric and hence we have to solve for three unknowns.
\[\log_{\mathcal G}(g) = X.\]
This result can be computed in-place of X
Note the logarithmic map is only locally around the identity uniquely determined. Especially, since $\mathrm{O}(3)$ consists of two disjoint connected components and the exponential map is smooth, for any $g$ in the other component, the logarithmic map is defined, but not the inverse of the exponential map.
ManifoldsBase.log!
— Methodlog(G, g)
log!(G, X, g)
Compute the Lie group logarithm function on the OrthogonalGroup
$\mathrm{O}(4)$ or SpecialOrthogonalGroup
$\mathrm{SO}(4)$, where e
is the Identity
{MatrixMultiplicationGroupOperation}
and G
uses a TypeParameter
for dispatch.
The implementation is based on a generalized variant of the Rodrigues' like formula. For details, see [GX02, Section 3].
This result can be computed in-place of X
Note the logarithmic map is only locally around the identity uniquely determined.
Utility functions
LieGroups.angles_4d_skew_sym_matrix
— Functionangles_4d_skew_sym_matrix(A)
The Lie algebra $𝔰𝔬(4)$ of OrthogonalGroup
(4)
in $ℝ^{4×4}$, consists of $4×4$ skew-symmetric matrices. The unique imaginary components of their eigenvalues are the angles of the two plane rotations. This function computes these more efficiently than eigvals
.
By convention, the returned values are sorted in decreasing order. See also cos_angles_4d_rotation_matrix
.
LieGroups.cos_angles_4d_rotation_matrix
— Functioncos_angles_4d_rotation_matrix(R)
4D rotations can be described by two orthogonal planes that are unchanged by the action of the rotation (vectors within a plane rotate only within the plane). The cosines of the two angles $α,β$ of rotation about these planes may be obtained from the distinct real parts of the eigenvalues of the rotation matrix. This function computes these more efficiently by solving the system
\[\begin{aligned} \cosα + \cosβ &= \frac{1}{2}\mathrm{tr}(R)\\ \cosα \cosβ &= \frac{1}{8}\mathrm{tr}(R)^2 - \frac{1}{16}\mathrm{tr}((R - R^T)^2) - 1\end{aligned}\]
By convention, the returned values are sorted in decreasing order. See also angles_4d_skew_sym_matrix
.
LieGroups.log_safe!
— Functionlog_safe!(y, x)
Compute the matrix logarithm of x
. If the eltype of y
is real, then the imaginary part of x
is ignored, and a DomainError
is raised if real(x)
has no real logarithm.
LieGroups.usinc_from_cos
— Functionusinc_from_cos(x::Real)
Unnormalized version of sinc
function, i.e. $\mathrm{usinc}(θ) = \frac{\sin(θ)}{θ}$, computed from $x = cos(θ)$.