pub struct SO3 { /* private fields */ }Expand description
SO(3) group element representing rotations in 3D.
Internally represented using nalgebra’s UnitQuaternion
Implementations§
Source§impl SO3
impl SO3
Sourcepub const DIM: usize = 3
pub const DIM: usize = 3
Space dimension - dimension of the ambient space that the group acts on
Sourcepub fn identity() -> SO3
pub fn identity() -> SO3
Get the identity element of the group.
Returns the neutral element e such that e ∘ g = g ∘ e = g for any group element g.
Sourcepub fn jacobian_identity() -> Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>
pub fn jacobian_identity() -> Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>
Get the identity matrix for Jacobians.
Returns the identity matrix in the appropriate dimension for Jacobian computations.
Sourcepub fn new(quaternion: Unit<Quaternion<f64>>) -> SO3
pub fn new(quaternion: Unit<Quaternion<f64>>) -> SO3
Create a new SO(3) element from a unit quaternion.
§Arguments
quaternion- Unit quaternion representing rotation
Sourcepub fn from_quaternion_coeffs(x: f64, y: f64, z: f64, w: f64) -> SO3
pub fn from_quaternion_coeffs(x: f64, y: f64, z: f64, w: f64) -> SO3
Create SO(3) from quaternion coefficients in G2O convention [x, y, z, w].
This parameter order matches the G2O file format where quaternion components
are stored as (qx, qy, qz, qw). For nalgebra’s (w, x, y, z) convention,
use from_quaternion_wxyz().
§Arguments
x- i component of quaterniony- j component of quaternionz- k component of quaternionw- w (real) component of quaternion
Sourcepub fn from_quaternion_wxyz(w: f64, x: f64, y: f64, z: f64) -> SO3
pub fn from_quaternion_wxyz(w: f64, x: f64, y: f64, z: f64) -> SO3
Create SO(3) from quaternion coefficients in nalgebra convention [w, x, y, z].
This parameter order matches nalgebra’s Quaternion::new(w, x, y, z).
For G2O file format order (qx, qy, qz, qw), use
from_quaternion_coeffs().
§Arguments
w- w (real) component of quaternionx- i component of quaterniony- j component of quaternionz- k component of quaternion
Sourcepub fn from_euler_angles(roll: f64, pitch: f64, yaw: f64) -> SO3
pub fn from_euler_angles(roll: f64, pitch: f64, yaw: f64) -> SO3
Create SO(3) from Euler angles (roll, pitch, yaw).
Sourcepub fn from_axis_angle(
axis: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
angle: f64,
) -> SO3
pub fn from_axis_angle( axis: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, angle: f64, ) -> SO3
Create SO(3) from axis-angle representation.
Sourcepub fn from_scaled_axis(
axis_angle: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
) -> SO3
pub fn from_scaled_axis( axis_angle: Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, ) -> SO3
Create SO(3) from scaled axis (axis-angle vector).
Sourcepub fn quaternion(&self) -> Unit<Quaternion<f64>>
pub fn quaternion(&self) -> Unit<Quaternion<f64>>
Get the quaternion representation.
Sourcepub fn from_quaternion(quaternion: Unit<Quaternion<f64>>) -> SO3
pub fn from_quaternion(quaternion: Unit<Quaternion<f64>>) -> SO3
Create SO3 from quaternion (alias for new)
Sourcepub fn to_quaternion(&self) -> Unit<Quaternion<f64>>
pub fn to_quaternion(&self) -> Unit<Quaternion<f64>>
Get the quaternion representation (alias for quaternion)
Sourcepub fn quat(&self) -> Quaternion<f64>
pub fn quat(&self) -> Quaternion<f64>
Get the raw quaternion coefficients.
Sourcepub fn rotation_matrix(
&self,
) -> Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>
pub fn rotation_matrix( &self, ) -> Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>
Get the rotation matrix (3x3).
Sourcepub fn transform(
&self,
) -> Matrix<f64, Const<4>, Const<4>, ArrayStorage<f64, 4, 4>>
pub fn transform( &self, ) -> Matrix<f64, Const<4>, Const<4>, ArrayStorage<f64, 4, 4>>
Get the homogeneous transformation matrix (4x4).
Sourcepub fn set_quaternion(&mut self, coeffs: &[f64; 4])
pub fn set_quaternion(&mut self, coeffs: &[f64; 4])
Set the quaternion from coefficients array [w, x, y, z].
Trait Implementations§
Source§impl LieGroup for SO3
impl LieGroup for SO3
Source§fn compose(
&self,
other: &SO3,
jacobian_self: Option<&mut <SO3 as LieGroup>::JacobianMatrix>,
jacobian_other: Option<&mut <SO3 as LieGroup>::JacobianMatrix>,
) -> SO3
fn compose( &self, other: &SO3, jacobian_self: Option<&mut <SO3 as LieGroup>::JacobianMatrix>, jacobian_other: Option<&mut <SO3 as LieGroup>::JacobianMatrix>, ) -> SO3
SO3 composition.
§Arguments
other- Another SO3 element.jacobian_self- Optional Jacobian matrix of the composition wrt self.jacobian_other- Optional Jacobian matrix of the composition wrt other.
§Notes
§Equation 141: Jacobian of the composition wrt self.
J_QR_R = Adj(R⁻¹) = Rᵀ
§Equation 142: Jacobian of the composition wrt other.
J_QR_Q = I
Source§fn log(
&self,
jacobian: Option<&mut <SO3 as LieGroup>::JacobianMatrix>,
) -> <SO3 as LieGroup>::TangentVector
fn log( &self, jacobian: Option<&mut <SO3 as LieGroup>::JacobianMatrix>, ) -> <SO3 as LieGroup>::TangentVector
Get the SO3 corresponding Lie algebra element in vector form.
§Arguments
jacobian- Optional Jacobian matrix of the tangent wrt to self.
§Notes
§Equation 133: Logarithmic map for unit quaternions (S³)
θu = Log(q) = (2 / ||v||) * v * arctan(||v||, w) ∈ R³
§Equation 144: Inverse of Right Jacobian for SO(3) Exp map
J_R⁻¹(θ) = I + (1/2) [θ]ₓ + (1/θ² - (1 + cos θ)/(2θ sin θ)) [θ]ₓ²
Source§fn vee(&self) -> <SO3 as LieGroup>::TangentVector
fn vee(&self) -> <SO3 as LieGroup>::TangentVector
Vee operator: log(g)^∨.
Maps a group element g ∈ G to its tangent vector log(g)^∨ ∈ 𝔤. For SO(3), this is the same as log().
Source§fn is_approx(&self, other: &SO3, tolerance: f64) -> bool
fn is_approx(&self, other: &SO3, tolerance: f64) -> bool
Check if the element is approximately equal to another element.
§Arguments
other- The other element to compare withtolerance- The tolerance for the comparison
Source§type TangentVector = SO3Tangent
type TangentVector = SO3Tangent
Source§type JacobianMatrix = Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>
type JacobianMatrix = Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>
Source§type LieAlgebra = Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>
type LieAlgebra = Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>
Source§fn act(
&self,
vector: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>,
jacobian_self: Option<&mut <SO3 as LieGroup>::JacobianMatrix>,
jacobian_vector: Option<&mut Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>>,
) -> Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>
fn act( &self, vector: &Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>, jacobian_self: Option<&mut <SO3 as LieGroup>::JacobianMatrix>, jacobian_vector: Option<&mut Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>>, ) -> Matrix<f64, Const<3>, Const<1>, ArrayStorage<f64, 3, 1>>
Source§fn jacobian_identity() -> <SO3 as LieGroup>::JacobianMatrix
fn jacobian_identity() -> <SO3 as LieGroup>::JacobianMatrix
Source§fn zero_jacobian() -> <SO3 as LieGroup>::JacobianMatrix
fn zero_jacobian() -> <SO3 as LieGroup>::JacobianMatrix
Source§fn is_valid(&self, tolerance: f64) -> bool
fn is_valid(&self, tolerance: f64) -> bool
Source§fn right_plus(
&self,
tangent: &Self::TangentVector,
jacobian_self: Option<&mut Self::JacobianMatrix>,
jacobian_tangent: Option<&mut Self::JacobianMatrix>,
) -> Self
fn right_plus( &self, tangent: &Self::TangentVector, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_tangent: Option<&mut Self::JacobianMatrix>, ) -> Self
Source§fn right_minus(
&self,
other: &Self,
jacobian_self: Option<&mut Self::JacobianMatrix>,
jacobian_other: Option<&mut Self::JacobianMatrix>,
) -> Self::TangentVector
fn right_minus( &self, other: &Self, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_other: Option<&mut Self::JacobianMatrix>, ) -> Self::TangentVector
Source§fn left_plus(
&self,
tangent: &Self::TangentVector,
jacobian_tangent: Option<&mut Self::JacobianMatrix>,
jacobian_self: Option<&mut Self::JacobianMatrix>,
) -> Self
fn left_plus( &self, tangent: &Self::TangentVector, jacobian_tangent: Option<&mut Self::JacobianMatrix>, jacobian_self: Option<&mut Self::JacobianMatrix>, ) -> Self
Source§fn left_minus(
&self,
other: &Self,
jacobian_self: Option<&mut Self::JacobianMatrix>,
jacobian_other: Option<&mut Self::JacobianMatrix>,
) -> Self::TangentVector
fn left_minus( &self, other: &Self, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_other: Option<&mut Self::JacobianMatrix>, ) -> Self::TangentVector
Source§fn plus(
&self,
tangent: &Self::TangentVector,
jacobian_self: Option<&mut Self::JacobianMatrix>,
jacobian_tangent: Option<&mut Self::JacobianMatrix>,
) -> Self
fn plus( &self, tangent: &Self::TangentVector, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_tangent: Option<&mut Self::JacobianMatrix>, ) -> Self
Source§fn minus(
&self,
other: &Self,
jacobian_self: Option<&mut Self::JacobianMatrix>,
jacobian_other: Option<&mut Self::JacobianMatrix>,
) -> Self::TangentVector
fn minus( &self, other: &Self, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_other: Option<&mut Self::JacobianMatrix>, ) -> Self::TangentVector
Source§fn between(
&self,
other: &Self,
jacobian_self: Option<&mut Self::JacobianMatrix>,
jacobian_other: Option<&mut Self::JacobianMatrix>,
) -> Self
fn between( &self, other: &Self, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_other: Option<&mut Self::JacobianMatrix>, ) -> Self
Source§fn tangent_dim(&self) -> usize
fn tangent_dim(&self) -> usize
Source§impl Tangent<SO3> for SO3Tangent
impl Tangent<SO3> for SO3Tangent
Source§fn exp(&self, jacobian: Option<&mut <SO3 as LieGroup>::JacobianMatrix>) -> SO3
fn exp(&self, jacobian: Option<&mut <SO3 as LieGroup>::JacobianMatrix>) -> SO3
SO3 exponential map.
§Arguments
tangent- Tangent vector [θx, θy, θz]jacobian- Optional Jacobian matrix of the SO3 element wrt self.
§Notes
§Equation 132: Exponential map for unit quaternions (S³)
q = Exp(θu) = cos(θ/2) + u sin(θ/2) ∈ H
§Equation 143: Right Jacobian for SO(3) Exp map
J_R(θ) = I - (1 - cos θ)/θ² [θ]ₓ + (θ - sin θ)/θ³ [θ]ₓ²
Source§fn right_jacobian(&self) -> <SO3 as LieGroup>::JacobianMatrix
fn right_jacobian(&self) -> <SO3 as LieGroup>::JacobianMatrix
Source§fn left_jacobian(&self) -> <SO3 as LieGroup>::JacobianMatrix
fn left_jacobian(&self) -> <SO3 as LieGroup>::JacobianMatrix
Source§fn right_jacobian_inv(&self) -> <SO3 as LieGroup>::JacobianMatrix
fn right_jacobian_inv(&self) -> <SO3 as LieGroup>::JacobianMatrix
Right Jacobian inverse for SO(3)
§Notes
§Equation 145: Right Jacobian inverse for SO(3) Exp map
J_R⁻¹(θ) = I + (1 - cos θ)/θ² [θ]ₓ + (θ - sin θ)/θ³ [θ]ₓ²
§Numerical Conditioning Warning
This function has inherent numerical conditioning issues that cannot be eliminated.
The formula contains the term (1 + cos θ) / (2θ sin θ) which:
- Becomes indeterminate (0/0) as θ → 0
- Has a singularity as θ → π (sin θ → 0)
- Amplifies floating-point errors for θ > 0.5 rad
Expected Precision:
- θ < 0.01 rad: Jr * Jr⁻¹ ≈ I within ~1e-6
- 0.01 < θ < 0.1 rad: Jr * Jr⁻¹ ≈ I within ~1e-4
- θ > 0.1 rad: Jr * Jr⁻¹ ≈ I within ~0.01
This is mathematically unavoidable and is consistent with all production Lie group libraries (manif, Sophus, GTSAM). See module documentation for references.
Source§fn left_jacobian_inv(&self) -> <SO3 as LieGroup>::JacobianMatrix
fn left_jacobian_inv(&self) -> <SO3 as LieGroup>::JacobianMatrix
Left Jacobian inverse for SO(3)
§Notes
§Equation 146: Left Jacobian inverse for SO(3) Exp map
J_L⁻¹(θ) = I - (1/2) [θ]ₓ + (1/θ² - (1 + cos θ)/(2θ sin θ)) [θ]ₓ²
§Numerical Conditioning Warning
This function has inherent numerical conditioning issues that cannot be eliminated.
The problematic term 1/θ² - (1 + cos θ)/(2θ sin θ) exhibits:
- Catastrophic cancellation as θ → 0 (requires Taylor series expansion)
- Division by zero as θ → π (sin θ → 0)
- Poor conditioning for θ > 0.5 rad (~29°)
Expected Precision (same as right Jacobian inverse):
- θ < 0.01 rad: Jl * Jl⁻¹ ≈ I within ~1e-6
- 0.01 < θ < 0.1 rad: Jl * Jl⁻¹ ≈ I within ~1e-4
- θ > 0.1 rad: Jl * Jl⁻¹ ≈ I within ~0.01
This is a fundamental mathematical limitation documented in:
- Nurlanov et al. (2021): SO(3) log map degeneracies
- Sophus library: https://github.com/strasdat/Sophus/issues/179
Source§fn small_adj(&self) -> <SO3 as LieGroup>::JacobianMatrix
fn small_adj(&self) -> <SO3 as LieGroup>::JacobianMatrix
Small adjoint matrix for SO(3).
For SO(3), the small adjoint is the skew-symmetric matrix (hat operator).
Source§fn lie_bracket(&self, other: &SO3Tangent) -> <SO3 as LieGroup>::TangentVector
fn lie_bracket(&self, other: &SO3Tangent) -> <SO3 as LieGroup>::TangentVector
Lie bracket for SO(3).
Computes the Lie bracket [this, other] = this.small_adj() * other.
Source§fn is_approx(&self, other: &SO3Tangent, tolerance: f64) -> bool
fn is_approx(&self, other: &SO3Tangent, tolerance: f64) -> bool
Check if this tangent vector is approximately equal to another.
§Arguments
other- The other tangent vector to compare withtolerance- The tolerance for the comparison
Source§fn normalized(&self) -> <SO3 as LieGroup>::TangentVector
fn normalized(&self) -> <SO3 as LieGroup>::TangentVector
Source§fn is_dynamic() -> bool
fn is_dynamic() -> bool
impl StructuralPartialEq for SO3
Auto Trait Implementations§
impl Freeze for SO3
impl RefUnwindSafe for SO3
impl Send for SO3
impl Sync for SO3
impl Unpin for SO3
impl UnsafeUnpin for SO3
impl UnwindSafe for SO3
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.