Skip to main content

SO3

Struct SO3 

Source
pub struct SO3 { /* private fields */ }
Expand description

SO(3) group element representing rotations in 3D.

Internally represented using nalgebra’s UnitQuaternion for efficient rotations.

Implementations§

Source§

impl SO3

Source

pub const DIM: usize = 3

Space dimension - dimension of the ambient space that the group acts on

Source

pub const DOF: usize = 3

Degrees of freedom - dimension of the tangent space

Source

pub const REP_SIZE: usize = 4

Representation size - size of the underlying data representation

Source

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.

Source

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.

Source

pub fn new(quaternion: Unit<Quaternion<f64>>) -> SO3

Create a new SO(3) element from a unit quaternion.

§Arguments
  • quaternion - Unit quaternion representing rotation
Source

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 quaternion
  • y - j component of quaternion
  • z - k component of quaternion
  • w - w (real) component of quaternion
Source

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 quaternion
  • x - i component of quaternion
  • y - j component of quaternion
  • z - k component of quaternion
Source

pub fn from_euler_angles(roll: f64, pitch: f64, yaw: f64) -> SO3

Create SO(3) from Euler angles (roll, pitch, yaw).

Source

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.

Source

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).

Source

pub fn quaternion(&self) -> Unit<Quaternion<f64>>

Get the quaternion representation.

Source

pub fn from_quaternion(quaternion: Unit<Quaternion<f64>>) -> SO3

Create SO3 from quaternion (alias for new)

Source

pub fn to_quaternion(&self) -> Unit<Quaternion<f64>>

Get the quaternion representation (alias for quaternion)

Source

pub fn quat(&self) -> Quaternion<f64>

Get the raw quaternion coefficients.

Source

pub fn x(&self) -> f64

Get the x component of the quaternion.

Source

pub fn y(&self) -> f64

Get the y component of the quaternion.

Source

pub fn z(&self) -> f64

Get the z component of the quaternion.

Source

pub fn w(&self) -> f64

Get the w component of the quaternion.

Source

pub fn rotation_matrix( &self, ) -> Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>

Get the rotation matrix (3x3).

Source

pub fn transform( &self, ) -> Matrix<f64, Const<4>, Const<4>, ArrayStorage<f64, 4, 4>>

Get the homogeneous transformation matrix (4x4).

Source

pub fn set_quaternion(&mut self, coeffs: &[f64; 4])

Set the quaternion from coefficients array [w, x, y, z].

Source

pub fn coeffs(&self) -> [f64; 4]

Get coefficients as array [w, x, y, z].

Source

pub fn distance(&self, other: &SO3) -> f64

Calculate the distance between two SO3 elements

Computes the geodesic distance, which is the norm of the log map of the relative rotation between the two elements.

Trait Implementations§

Source§

impl Clone for SO3

Source§

fn clone(&self) -> SO3

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Display for SO3

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>> for SO3

Source§

fn from(data: Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>) -> SO3

Converts to this type from the input type.
Source§

impl LieGroup for SO3

Source§

fn inverse( &self, jacobian: Option<&mut <SO3 as LieGroup>::JacobianMatrix>, ) -> SO3

SO3 inverse.

§Arguments
  • jacobian - Optional Jacobian matrix of the inverse wrt self.
§Notes

R⁻¹ = Rᵀ, for quaternions: q⁻¹ = q*

§Equation 140: Jacobian of Inverse for SO(3)

J_R⁻¹_R = -Adj(R) = -R

Source§

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

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

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

Check if the element is approximately equal to another element.

§Arguments
  • other - The other element to compare with
  • tolerance - The tolerance for the comparison
Source§

type TangentVector = SO3Tangent

The tangent space vector type
Source§

type JacobianMatrix = Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>

The Jacobian matrix type
Source§

type LieAlgebra = Matrix<f64, Const<3>, Const<3>, ArrayStorage<f64, 3, 3>>

Associated Lie algebra type
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>>

Act on a vector v: g ⊙ v. Read more
Source§

fn adjoint(&self) -> <SO3 as LieGroup>::JacobianMatrix

Adjoint matrix Ad(g). Read more
Source§

fn random() -> SO3

Generate a random element (useful for testing and initialization).
Source§

fn jacobian_identity() -> <SO3 as LieGroup>::JacobianMatrix

Get the identity matrix for Jacobians. Read more
Source§

fn zero_jacobian() -> <SO3 as LieGroup>::JacobianMatrix

Get a zero Jacobian matrix. Read more
Source§

fn normalize(&mut self)

Normalize/project the element to the manifold. Read more
Source§

fn is_valid(&self, tolerance: f64) -> bool

Check if the element is approximately on the manifold.
Source§

fn right_plus( &self, tangent: &Self::TangentVector, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_tangent: Option<&mut Self::JacobianMatrix>, ) -> Self

Right plus operation: g ⊞ φ = g ∘ exp(φ^∧). Read more
Source§

fn right_minus( &self, other: &Self, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_other: Option<&mut Self::JacobianMatrix>, ) -> Self::TangentVector

Right minus operation: g₁ ⊟ g₂ = log(g₂⁻¹ ∘ g₁)^∨. Read more
Source§

fn left_plus( &self, tangent: &Self::TangentVector, jacobian_tangent: Option<&mut Self::JacobianMatrix>, jacobian_self: Option<&mut Self::JacobianMatrix>, ) -> Self

Left plus operation: φ ⊞ g = exp(φ^∧) ∘ g. Read more
Source§

fn left_minus( &self, other: &Self, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_other: Option<&mut Self::JacobianMatrix>, ) -> Self::TangentVector

Left minus operation: g₁ ⊟ g₂ = log(g₁ ∘ g₂⁻¹)^∨. Read more
Source§

fn plus( &self, tangent: &Self::TangentVector, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_tangent: Option<&mut Self::JacobianMatrix>, ) -> Self

Convenience method for right_plus. Equivalent to g ⊞ φ.
Source§

fn minus( &self, other: &Self, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_other: Option<&mut Self::JacobianMatrix>, ) -> Self::TangentVector

Convenience method for right_minus. Equivalent to g₁ ⊟ g₂.
Source§

fn between( &self, other: &Self, jacobian_self: Option<&mut Self::JacobianMatrix>, jacobian_other: Option<&mut Self::JacobianMatrix>, ) -> Self

Compute g₁⁻¹ ∘ g₂ (relative transformation). Read more
Source§

fn tangent_dim(&self) -> usize

Get the dimension of the tangent space for this manifold element. Read more
Source§

impl PartialEq for SO3

Source§

fn eq(&self, other: &SO3) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Tangent<SO3> for SO3Tangent

Source§

const DIM: usize = 3

Dimension of the tangent space

Source§

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

Right Jacobian for SO(3)

§Notes
§Equation 143: Right Jacobian for SO(3) Exp map

J_R(θ) = I - (1 - cos θ)/θ² [θ]ₓ + (θ - sin θ)/θ³ [θ]ₓ²

Source§

fn left_jacobian(&self) -> <SO3 as LieGroup>::JacobianMatrix

Left Jacobian for SO(3)

§Notes
§Equation 144: Left Jacobian for SO(3) Exp map

J_R⁻¹(θ) = I + (1 - cos θ)/θ² [θ]ₓ + (θ - sin θ)/θ³ [θ]ₓ²

Source§

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

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:

Source§

fn hat(&self) -> <SO3 as LieGroup>::LieAlgebra

Hat map for SO(3)

§Notes

[θ]ₓ = [0 -θz θy; θz 0 -θx; -θy θx 0]

Source§

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

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

Check if this tangent vector is approximately equal to another.

§Arguments
  • other - The other tangent vector to compare with
  • tolerance - The tolerance for the comparison
Source§

fn generator(&self, i: usize) -> <SO3 as LieGroup>::LieAlgebra

Get the ith generator of the SO(3) Lie algebra.

§Arguments
  • i - Index of the generator (0, 1, or 2 for SO(3))
§Returns

The generator matrix

Source§

fn zero() -> <SO3 as LieGroup>::TangentVector

Zero tangent vector.
Source§

fn random() -> <SO3 as LieGroup>::TangentVector

Random tangent vector (useful for testing).
Source§

fn is_zero(&self, tolerance: f64) -> bool

Check if the tangent vector is approximately zero.
Source§

fn normalize(&mut self)

Normalize the tangent vector to unit norm.
Source§

fn normalized(&self) -> <SO3 as LieGroup>::TangentVector

Return a unit tangent vector in the same direction.
Source§

fn is_dynamic() -> bool

Whether this tangent type has dynamic (runtime-determined) dimension. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more