clifford 0.3.0

Geometric Algebra (Clifford Algebra) for Rust: rotors, motors, PGA for 3D rotations and rigid transforms
Documentation
#![doc = " Multivector conversions for euclidean2."]
#![doc = ""]
#![doc = " This file is auto-generated by clifford-codegen."]
#![doc = " Do not edit manually."]
use super::types::{Bivector, Rotor, Scalar, Vector};
use crate::algebra::Multivector;
use crate::basis::Blade;
use crate::scalar::Float;
use crate::signature::Euclidean2;
impl<T: Float> From<Bivector<T>> for Multivector<T, Euclidean2> {
    fn from(value: Bivector<T>) -> Self {
        Self::from_coeffs(&[T::zero(), T::zero(), T::zero(), value.b()])
    }
}
impl<T: Float> From<Rotor<T>> for Multivector<T, Euclidean2> {
    fn from(value: Rotor<T>) -> Self {
        Self::from_coeffs(&[value.s(), T::zero(), T::zero(), value.b()])
    }
}
impl<T: Float> From<Scalar<T>> for Multivector<T, Euclidean2> {
    fn from(value: Scalar<T>) -> Self {
        Self::from_coeffs(&[value.s(), T::zero(), T::zero(), T::zero()])
    }
}
impl<T: Float> From<Vector<T>> for Multivector<T, Euclidean2> {
    fn from(value: Vector<T>) -> Self {
        Self::from_coeffs(&[T::zero(), value.x(), value.y(), T::zero()])
    }
}
impl<T: Float> From<Multivector<T, Euclidean2>> for Bivector<T> {
    #[doc = r" Extracts this type from a multivector."]
    #[doc = r""]
    #[doc = r" Note: This is a lossy projection that only extracts the relevant"]
    #[doc = r" grades. Other components of the multivector are discarded."]
    fn from(mv: Multivector<T, Euclidean2>) -> Self {
        Self::new_unchecked(mv.get(Blade::from_index(3usize)))
    }
}
impl<T: Float> From<Multivector<T, Euclidean2>> for Rotor<T> {
    #[doc = r" Extracts this type from a multivector."]
    #[doc = r""]
    #[doc = r" Note: This is a lossy projection that only extracts the relevant"]
    #[doc = r" grades. Other components of the multivector are discarded."]
    fn from(mv: Multivector<T, Euclidean2>) -> Self {
        Self::new_unchecked(
            mv.get(Blade::from_index(0usize)),
            mv.get(Blade::from_index(3usize)),
        )
    }
}
impl<T: Float> From<Multivector<T, Euclidean2>> for Scalar<T> {
    #[doc = r" Extracts this type from a multivector."]
    #[doc = r""]
    #[doc = r" Note: This is a lossy projection that only extracts the relevant"]
    #[doc = r" grades. Other components of the multivector are discarded."]
    fn from(mv: Multivector<T, Euclidean2>) -> Self {
        Self::new_unchecked(mv.get(Blade::from_index(0usize)))
    }
}
impl<T: Float> From<Multivector<T, Euclidean2>> for Vector<T> {
    #[doc = r" Extracts this type from a multivector."]
    #[doc = r""]
    #[doc = r" Note: This is a lossy projection that only extracts the relevant"]
    #[doc = r" grades. Other components of the multivector are discarded."]
    fn from(mv: Multivector<T, Euclidean2>) -> Self {
        Self::new_unchecked(
            mv.get(Blade::from_index(1usize)),
            mv.get(Blade::from_index(2usize)),
        )
    }
}