clifford 0.3.0

Geometric Algebra (Clifford Algebra) for Rust: rotors, motors, PGA for 3D rotations and rigid transforms
Documentation
#![doc = " Multivector conversions for complex."]
#![doc = ""]
#![doc = " This file is auto-generated by clifford-codegen."]
#![doc = " Do not edit manually."]
use super::types::{Complex, ImagUnit, Scalar};
use crate::algebra::Multivector;
use crate::basis::Blade;
use crate::scalar::Float;
use crate::signature::Cl0_1_0;
impl<T: Float> From<Complex<T>> for Multivector<T, Cl0_1_0> {
    fn from(value: Complex<T>) -> Self {
        Self::from_coeffs(&[value.real(), value.imag()])
    }
}
impl<T: Float> From<ImagUnit<T>> for Multivector<T, Cl0_1_0> {
    fn from(value: ImagUnit<T>) -> Self {
        Self::from_coeffs(&[T::zero(), value.i()])
    }
}
impl<T: Float> From<Scalar<T>> for Multivector<T, Cl0_1_0> {
    fn from(value: Scalar<T>) -> Self {
        Self::from_coeffs(&[value.s(), T::zero()])
    }
}
impl<T: Float> From<Multivector<T, Cl0_1_0>> for Complex<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, Cl0_1_0>) -> Self {
        Self::new_unchecked(
            mv.get(Blade::from_index(0usize)),
            mv.get(Blade::from_index(1usize)),
        )
    }
}
impl<T: Float> From<Multivector<T, Cl0_1_0>> for ImagUnit<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, Cl0_1_0>) -> Self {
        Self::new_unchecked(mv.get(Blade::from_index(1usize)))
    }
}
impl<T: Float> From<Multivector<T, Cl0_1_0>> 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, Cl0_1_0>) -> Self {
        Self::new_unchecked(mv.get(Blade::from_index(0usize)))
    }
}