pub struct SymmetricMat3(/* private fields */);Expand description
A memory-efficient 3×3 symmetric matrix for spatial algebra operations.
This structure stores a symmetric 3×3 matrix using only 6 elements instead of 9,
exploiting the mathematical property that a_ij = a_ji for symmetric matrices.
This provides significant memory savings and computational efficiency for
inertia tensors and other symmetric operations in spatial algebra.
§Storage Format
The matrix is stored in column-major order, containing the lower triangular elements of the symmetric matrix:
Stored array: [a₀₀, a₁₀, a₂₀, a₁₁, a₂₁, a₂₂]
Full matrix:
| a₀₀ a₀₁ a₀₂ |
| a₁₀ a₁₁ a₁₂ | where a_ij = a_ji
| a₂₀ a₂₁ a₂₂ |§Applications in Spatial Algebra
- Rotational inertia tensors: Always symmetric, stored efficiently
- Covariance matrices: Common in state estimation and filtering
- Stiffness/damping matrices: Used in compliant dynamics
- Quadratic forms: Energy calculations and optimization
§Performance Benefits
- Memory: 33% reduction compared to full 3×3 matrix storage
- Cache efficiency: Compact layout improves memory access patterns
- Computation: Avoids redundant calculations on symmetric elements
Implementations§
Source§impl SymmetricMat3
impl SymmetricMat3
Sourcepub const ONE: Self
pub const ONE: Self
Identity matrix (diagonal elements are 1, off-diagonal are 0).
Represents the 3×3 identity matrix in symmetric storage format.
Sourcepub const ZERO: Self
pub const ZERO: Self
Zero matrix (all elements are 0).
Useful for initialization and as the additive identity.
Sourcepub fn from_array(array: [Real; 6]) -> Self
pub fn from_array(array: [Real; 6]) -> Self
Create a symmetric matrix from a 6-element array in column-major order.
§Input Format
The array should contain the lower triangular elements in column-major order:
array = [a₀₀, a₁₀, a₂₀, a₁₁, a₂₁, a₂₂]§Example
use spatial_math::SymmetricMat3;
// Create matrix |1 2 3|
// |2 4 5|
// |3 5 6|
let matrix = SymmetricMat3::from_array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]);pub fn from_iterator(iter: impl IntoIterator<Item = Real>) -> Self
pub fn mat3(&self) -> Mat3
pub fn mul_vec(&self, v: Vec3) -> Vec3
pub fn scale(&self, scalar: Real) -> Self
pub fn add(&self, rhs: Self) -> Self
pub fn sub(&self, rhs: Self) -> Self
pub fn into_array(self) -> [Real; 6]
Trait Implementations§
Source§impl Add for SymmetricMat3
impl Add for SymmetricMat3
Source§impl Clone for SymmetricMat3
impl Clone for SymmetricMat3
Source§fn clone(&self) -> SymmetricMat3
fn clone(&self) -> SymmetricMat3
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SymmetricMat3
impl Debug for SymmetricMat3
Source§impl Default for SymmetricMat3
impl Default for SymmetricMat3
Source§fn default() -> SymmetricMat3
fn default() -> SymmetricMat3
Source§impl From<Matrix<f32, Const<3>, Const<3>, ArrayStorage<f32, 3, 3>>> for SymmetricMat3
impl From<Matrix<f32, Const<3>, Const<3>, ArrayStorage<f32, 3, 3>>> for SymmetricMat3
Source§impl<RStride, CStride> From<Matrix<f32, Const<3>, Const<3>, ViewStorage<'_, f32, Const<3>, Const<3>, RStride, CStride>>> for SymmetricMat3
impl<RStride, CStride> From<Matrix<f32, Const<3>, Const<3>, ViewStorage<'_, f32, Const<3>, Const<3>, RStride, CStride>>> for SymmetricMat3
Source§fn from(mat: MatrixView3<'_, Real, RStride, CStride>) -> Self
fn from(mat: MatrixView3<'_, Real, RStride, CStride>) -> Self
Takes the lower triangle of the matrix and converts it into a SymmetricMat3.
Source§impl Mul<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>> for SymmetricMat3
impl Mul<Matrix<f32, Const<3>, Const<1>, ArrayStorage<f32, 3, 1>>> for SymmetricMat3
Source§impl Mul<f32> for SymmetricMat3
impl Mul<f32> for SymmetricMat3
Source§impl Sub for SymmetricMat3
impl Sub for SymmetricMat3
impl Copy for SymmetricMat3
Auto Trait Implementations§
impl Freeze for SymmetricMat3
impl RefUnwindSafe for SymmetricMat3
impl Send for SymmetricMat3
impl Sync for SymmetricMat3
impl Unpin for SymmetricMat3
impl UnwindSafe for SymmetricMat3
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<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.