MiniTensor Version of the Day
Loading...
Searching...
No Matches
Rotations

Logarithmic and exponential maps on SO(N), quaternions, and conversions among rotation representations: rotation matrix, unit quaternion and principal rotation vector. More...

Classes

class  minitensor::Quaternion< T >
 

Functions

template<typename T >
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::operator* (Quaternion< T > const &p, Quaternion< T > const &q)
 
template<typename T >
KOKKOS_INLINE_FUNCTION bool minitensor::operator== (Quaternion< T > const &p, Quaternion< T > const &q)
 
template<typename T >
KOKKOS_INLINE_FUNCTION bool minitensor::operator!= (Quaternion< T > const &p, Quaternion< T > const &q)
 
template<typename T >
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::conjugate (Quaternion< T > const &q)
 
template<typename T >
KOKKOS_INLINE_FUNCTIONminitensor::norm (Quaternion< T > const &q)
 
template<typename T >
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::inverse (Quaternion< T > const &q)
 
template<typename T >
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::unit (Quaternion< T > const &q)
 
template<typename T >
std::ostream & minitensor::operator<< (std::ostream &os, Quaternion< T > const &q)
 
template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::q_of_rt (Tensor< T, N > const &R)
 
template<typename T >
KOKKOS_INLINE_FUNCTION Vector< T, 3 > minitensor::rv_of_q (Quaternion< T > const &q)
 
template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::q_of_rv (Vector< T, N > const &rv)
 
template<typename T >
KOKKOS_INLINE_FUNCTION Tensor< T, 3 > minitensor::rt_of_q (Quaternion< T > const &q)
 
template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Vector< T, 3 > minitensor::rv_of_rt (Tensor< T, N > const &R)
 
template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Tensor< T, 3 > minitensor::rt_of_rv (Vector< T, N > const &rv)
 
template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Vector< T, N > minitensor::rv_continue (Vector< T, N > const &old, Vector< T, N > const &prev)
 
template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Tensor< T, N > minitensor::log_rotation (Tensor< T, N > const &R)
 
template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Tensor< T, N > minitensor::log_rotation_pi (Tensor< T, N > const &R)
 
template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Tensor< T, N > minitensor::exp_skew_symmetric (Tensor< T, N > const &r)
 
template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Vector< T, N > minitensor::vee (Tensor< T, N > const &W)
 

Detailed Description

Logarithmic and exponential maps on SO(N), quaternions, and conversions among rotation representations: rotation matrix, unit quaternion and principal rotation vector.

Function Documentation

◆ operator*()

template<typename T >
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::operator* ( Quaternion< T > const &  p,
Quaternion< T > const &  q 
)

Hamilton product of two quaternions

Parameters
pquaternion
qquaternion
Returns
\( p q = (p_s q_s - p_v \cdot q_v; \; p_s q_v + q_s p_v + p_v \times q_v) \)

Definition at line 393 of file MiniTensor_Quaternion.h.

◆ operator==()

template<typename T >
KOKKOS_INLINE_FUNCTION bool minitensor::operator== ( Quaternion< T > const &  p,
Quaternion< T > const &  q 
)

Quaternion equality, tested component-wise.

Parameters
pquaternion
qquaternion

Definition at line 411 of file MiniTensor_Quaternion.h.

◆ operator!=()

template<typename T >
KOKKOS_INLINE_FUNCTION bool minitensor::operator!= ( Quaternion< T > const &  p,
Quaternion< T > const &  q 
)

Quaternion inequality, tested component-wise.

Parameters
pquaternion
qquaternion

Definition at line 422 of file MiniTensor_Quaternion.h.

◆ conjugate()

template<typename T >
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::conjugate ( Quaternion< T > const &  q)

Quaternion conjugate

Parameters
qquaternion
Returns
\( \bar{q} = (q_s; -q_v) \)

Definition at line 433 of file MiniTensor_Quaternion.h.

◆ norm()

template<typename T >
KOKKOS_INLINE_FUNCTION T minitensor::norm ( Quaternion< T > const &  q)

Quaternion norm

Parameters
qquaternion
Returns
\( \sqrt{q_s^2 + q_v \cdot q_v} \)

Definition at line 444 of file MiniTensor_Quaternion.h.

◆ inverse()

template<typename T >
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::inverse ( Quaternion< T > const &  q)

Quaternion inverse

Parameters
qquaternion
Returns
\( q^{-1} = \bar{q} / |q|^2 \)

Definition at line 456 of file MiniTensor_Quaternion.h.

◆ unit()

template<typename T >
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::unit ( Quaternion< T > const &  q)

Quaternion normalized to unit norm

Parameters
qquaternion
Returns
\( q / |q| \)

Definition at line 470 of file MiniTensor_Quaternion.h.

◆ operator<<()

template<typename T >
std::ostream & minitensor::operator<< ( std::ostream &  os,
Quaternion< T > const &  q 
)

Quaternion output, scalar-first components separated by commas.

Parameters
osoutput stream
qquaternion
Returns
os

Definition at line 482 of file MiniTensor_Quaternion.h.

◆ q_of_rt()

template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::q_of_rt ( Tensor< T, N > const &  R)

Quaternion of a rotation matrix, using Spurrier's singularity-free algorithm. Selects the largest of the trace and the diagonal entries of the matrix and computes the quaternion components accordingly, which ensures a stable evaluation for all rotation angles including \( \theta = \pi \).

Parameters
Rrotation matrix with \( R \in SO(3) \)
Returns
unit quaternion \( q \) such that rt_of_q(q) recovers R

Definition at line 502 of file MiniTensor_Quaternion.h.

◆ rv_of_q()

template<typename T >
KOKKOS_INLINE_FUNCTION Vector< T, 3 > minitensor::rv_of_q ( Quaternion< T > const &  q)

Principal rotation vector of a quaternion. The sign of the quaternion is first normalized so that \( q_s \geq 0 \), which selects the principal rotation \( |rv| \leq \pi \). Small rotations use an alternate evaluation to avoid numerical instability.

Parameters
qunit quaternion
Returns
rotation vector \( rv \) with \( |rv| \leq \pi \)

Definition at line 616 of file MiniTensor_Quaternion.h.

◆ q_of_rv()

template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Quaternion< T > minitensor::q_of_rv ( Vector< T, N > const &  rv)

Quaternion of a rotation vector, computed as \( q_s = \cos(|rv|/2) \), \( q_v = \frac{1}{2}\,\psi(|rv|/2)\, rv \) with \( \psi(x) = \sin(x)/x \), using asymptotic expansions of \( \psi \) for small angles.

Parameters
rvrotation vector
Returns
unit quaternion

Definition at line 663 of file MiniTensor_Quaternion.h.

◆ rt_of_q()

template<typename T >
KOKKOS_INLINE_FUNCTION Tensor< T, 3 > minitensor::rt_of_q ( Quaternion< T > const &  q)

Rotation matrix of a quaternion, based on the identity \( R = 2 q_v \otimes q_v + 2 q_s \mathrm{skew}(q_v) + (2 q_s^2 - 1) I \).

Parameters
qunit quaternion
Returns
rotation matrix \( R \in SO(3) \)

Definition at line 686 of file MiniTensor_Quaternion.h.

◆ rv_of_rt()

template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Vector< T, 3 > minitensor::rv_of_rt ( Tensor< T, N > const &  R)

Principal rotation vector of a rotation matrix, computed through the quaternion representation as rv_of_q(q_of_rt(R)). Unlike log_rotation, this path is singularity-free for all rotation angles including \( \theta = \pi \).

Parameters
Rrotation matrix with \( R \in SO(3) \)
Returns
rotation vector \( rv \) with \( |rv| \leq \pi \)

Definition at line 707 of file MiniTensor_Quaternion.h.

◆ rt_of_rv()

template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Tensor< T, 3 > minitensor::rt_of_rv ( Vector< T, N > const &  rv)

Rotation matrix of a rotation vector, computed through the quaternion representation as rt_of_q(q_of_rv(rv)).

Parameters
rvrotation vector
Returns
rotation matrix \( R \in SO(3) \)

Definition at line 718 of file MiniTensor_Quaternion.h.

◆ rv_continue()

template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Vector< T, N > minitensor::rv_continue ( Vector< T, N > const &  old,
Vector< T, N > const &  prev 
)

Rotation vector equivalent to old (representing the same rotation) but as close as possible to prev. Resolves the \( 2 \pi k \) ambiguity of the rotation-vector representation, which enforces continuity in incremental rotation updates such as time stepping.

Parameters
oldrotation vector to continue
prevprevious rotation vector
Returns
rotation vector equivalent to old and closest to prev

Definition at line 729 of file MiniTensor_Quaternion.h.

◆ log_rotation()

template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Tensor< T, N > minitensor::log_rotation ( Tensor< T, N > const &  R)

Logarithmic map of a rotation

Parameters
Rwith \( R \in SO(3) \)
Returns
\( r = \log R \) with \( r \in so(3) \)

Definition at line 71 of file MiniTensor_Rotations.h.

◆ log_rotation_pi()

template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Tensor< T, N > minitensor::log_rotation_pi ( Tensor< T, N > const &  R)

Logarithmic map of a 180 degree rotation

Parameters
Rwith \( R \in SO(3) \)
Returns
\( r = \log R \) with \( r \in so(3) \)

Definition at line 141 of file MiniTensor_Rotations.h.

◆ exp_skew_symmetric()

template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Tensor< T, N > minitensor::exp_skew_symmetric ( Tensor< T, N > const &  r)

Exponential map of a skew-symmetric tensor

Parameters
r\( r \in so(3) \)
Returns
\( R = \exp R \) with \( R \in SO(3) \)

Definition at line 229 of file MiniTensor_Rotations.h.

◆ vee()

template<typename T , Index N>
KOKKOS_INLINE_FUNCTION Vector< T, N > minitensor::vee ( Tensor< T, N > const &  W)

Axial vector of a skew-symmetric tensor, the inverse of skew(Vector). Defined for 3D only.

Parameters
Wskew-symmetric tensor \( W \in so(3) \)
Returns
\( w \) such that \( W u = w \times u \) for all \( u \)

Definition at line 292 of file MiniTensor_Rotations.h.