Skip to main content

GeometricState

Struct GeometricState 

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

State that lives in geometric space with explicit transformation support.

Unlike Behavior<T>, which hides the geometric representation, GeometricState exposes it directly. This is useful for:

  • Animation with geometric interpolation (SLERP)
  • Physics simulations
  • Explicit rotation/translation control
  • Advanced users who understand geometric algebra

Implementations§

Source§

impl GeometricState

Source

pub fn new(mv: GA3) -> Self

Create a new geometric state from a multivector

Source

pub fn from_scalar(value: f64) -> Self

Create state representing a scalar value

Source

pub fn from_vector(x: f64, y: f64, z: f64) -> Self

Create state representing a 3D vector/position

Source

pub fn from_bivector(xy: f64, xz: f64, yz: f64) -> Self

Create state representing a bivector (rotation plane)

Source

pub fn from_coefficients(coeffs: Vec<f64>) -> Self

Create state from raw coefficients

Source

pub fn zero() -> Self

Create the zero state

Source

pub fn identity() -> Self

Create the identity state (scalar 1)

Source

pub fn multivector(&self) -> GA3

Get the underlying multivector (cloned)

Source

pub fn get(&self, index: usize) -> f64

Get the raw coefficient at a given index

Source

pub fn scalar(&self) -> f64

Get the scalar component

Source

pub fn as_vector(&self) -> (f64, f64, f64)

Get the vector components (e1, e2, e3) as a tuple

Source

pub fn as_typed_vector(&self) -> Vector<3, 0, 0>

Get the vector components as a typed Vector<3,0,0>

Source

pub fn as_bivector(&self) -> (f64, f64, f64)

Get the bivector components (e12, e13, e23) as a tuple

Source

pub fn as_typed_bivector(&self) -> Bivector<3, 0, 0>

Get the bivector components as a typed Bivector<3,0,0>

Source

pub fn magnitude(&self) -> f64

Get the magnitude (norm) of the state

Source

pub fn project<P: Projection>(&self, projection: &P) -> P::Output

Project using a projection type

Source

pub fn set(&self, mv: GA3)

Set the state to a new multivector

Source

pub fn set_scalar(&self, value: f64)

Set the scalar value

Source

pub fn set_vector(&self, x: f64, y: f64, z: f64)

Set the vector value from components

Source

pub fn set_typed_vector(&self, v: &Vector<3, 0, 0>)

Set the vector value from a typed Vector<3,0,0>

Source

pub fn set_typed_bivector(&self, b: &Bivector<3, 0, 0>)

Set the bivector value from a typed Bivector<3,0,0>

Source

pub fn update<F>(&self, f: F)
where F: FnOnce(&GA3) -> GA3,

Update the state by applying a function

Source

pub fn apply_rotor(&self, rotor: &Rotor) -> GeometricState

Apply a rotor transformation (rotation)

This creates a new state; the original is unchanged.

Source

pub fn apply_rotor_mut(&self, rotor: &Rotor)

Apply a rotor transformation in-place

Source

pub fn apply_translation(&self, translation: &Translation) -> GeometricState

Apply a translation

This creates a new state; the original is unchanged.

Source

pub fn apply_translation_mut(&self, translation: &Translation)

Apply a translation in-place

Source

pub fn apply_versor(&self, versor: &Versor) -> GeometricState

Apply a versor transformation

This creates a new state; the original is unchanged.

Source

pub fn apply_versor_mut(&self, versor: &Versor)

Apply a versor transformation in-place

Source

pub fn apply_transform(&self, transform: &Transform) -> GeometricState

Apply a general transform (rotation + translation)

This creates a new state; the original is unchanged.

Source

pub fn apply_transform_mut(&self, transform: &Transform)

Apply a general transform in-place

Source

pub fn add(&self, other: &GeometricState) -> GeometricState

Add another state (geometric addition)

Source

pub fn sub(&self, other: &GeometricState) -> GeometricState

Subtract another state

Source

pub fn scale(&self, factor: f64) -> GeometricState

Scale by a scalar value

Source

pub fn geometric_product(&self, other: &GeometricState) -> GeometricState

Geometric product with another state

Source

pub fn normalize(&self) -> Option<GeometricState>

Normalize the state to unit magnitude

Source

pub fn normalize_mut(&self) -> bool

Normalize in-place

Source

pub fn reverse(&self) -> GeometricState

Get the reverse (reversion) of this state

Source

pub fn lerp(&self, other: &GeometricState, t: f64) -> GeometricState

Linear interpolation to another state

Source

pub fn slerp(&self, other: &GeometricState, t: f64) -> GeometricState

Spherical linear interpolation (for rotor-like states)

This assumes both states are unit rotors.

Source

pub fn subscribe<F>(&self, callback: F) -> GeometricSubscription
where F: Fn(&GA3) + Send + Sync + 'static,

Subscribe to state changes

Trait Implementations§

Source§

impl Clone for GeometricState

Source§

fn clone(&self) -> GeometricState

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 Debug for GeometricState

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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