Expand description
Represents a reflection in N
dimensions (with an optional rotation component)
Implementations
Unrwaps self
into its internal algebraic type
Unrwaps self
into a reference to its internal algebraic type
Creates a new value of Self
from an internal algebraic type
assuming that it satisfies all the guarrantees of this type
Safety
This function is not marked unsafe
since there is no way an invalid
argument could violate any of Rust’s memory safety rules. However, caution
should still be taken since an invalid input can still dramatically break
many other functions of this type.
Creates a rotation about the hyperplane normal to the given vector
Concretely, this produces a reflection that flips any components of blades in the direction of the given vector.
Same as Reflector::reflect_unit_normal()
, but performs an extra normalization step
which may be costly in certain contexts
Creates a rotation about the hyperplane normal to the given vector
Concretely, this produces a reflection that flips any components of blades in the direction of the given vector.
Same as Reflector::reflect_normal()
, but avoids an extra normalization step
which may be costly in certain contexts
pub fn reflect_hyperplane<G: Dim>(plane: Blade<T, N, G>) -> Self where
T: AllocBlade<N, G> + AllocBlade<N, U1> + RefRealField,
N: DimSub<G, Output = U1>,
pub fn reflect_hyperplane<G: Dim>(plane: Blade<T, N, G>) -> Self where
T: AllocBlade<N, G> + AllocBlade<N, U1> + RefRealField,
N: DimSub<G, Output = U1>,
Creates a rotation about the given hyperplane
Concretely, this produces a reflection that flips any components of blades perpendicular to the given hyperplane
Same as Reflector::reflect_unit_hyperplane()
, but performs an extra normalization step
which may be costly in certain contexts
pub fn reflect_unit_hyperplane<G: Dim>(plane: UnitBlade<T, N, G>) -> Self where
T: AllocBlade<N, G> + AllocBlade<N, U1> + ClosedNeg,
N: DimSub<G, Output = U1>,
pub fn reflect_unit_hyperplane<G: Dim>(plane: UnitBlade<T, N, G>) -> Self where
T: AllocBlade<N, G> + AllocBlade<N, U1> + ClosedNeg,
N: DimSub<G, Output = U1>,
Creates a rotation about the given hyperplane
Concretely, this produces a reflection that flips any components of blades perpendicular to the given hyperplane
Same as Reflector::reflect_unit_hyperplane()
, but avoids an extra normalization step
which may be costly in certain contexts
pub fn cast_dim_generic_unchecked<N2: Dim>(self, n: N2) -> Reflector<T, N2> where
T: AllocOdd<N2>,
pub fn cast_dim_generic_unchecked<N2: Dim>(self, n: N2) -> Reflector<T, N2> where
T: AllocOdd<N2>,
Embeds self
into a different dimension by either removing elements or inserting zeros
Embeds self
into a different dimension by either removing elements or inserting zeros
Embeds self
into a different dimension by either removing elements or inserting zeros
Methods from Deref<Target = Odd<T, N>>
Returns the dimension of this value as an instance of the generic type N
This is mostly used internally to unify the codebase between Const
dimensions
and Dynamic
dimensions. Since Dynamic
grades often require a usize
input when
Const
grades do not, this allows a function to take a ZST for static dimensions
and to take a numeric value for dynamic ones
The number of dimensions this value resides in
Note that this differs from both the grade and number of elements. Instead, this describes the dimension of the vector space generating the algebra this blade resides in.
Examples
//All of these live in 3-dimensions
let v = Vec3::new(3, 1, 4);
let b = BiVec3::new(6, 2, 8);
let r = Even3::new(1, 6, 1, 8);
let m = Multivector3::new(0, 5, 7, 7, 2, 1, 5, 6);
assert_eq!(v.dim(), 3);
assert_eq!(b.dim(), 3);
assert_eq!(r.dim(), 3);
assert_eq!(m.dim(), 3);
//whereas these are in 4D
let v = Vec4::from_element(6);
let b = BiVec4::from_element(2);
let r = Even4::from_element(8);
let m = Multivector4::from_element(3);
assert_eq!(v.dim(), 4);
assert_eq!(b.dim(), 4);
assert_eq!(r.dim(), 4);
assert_eq!(m.dim(), 4);
The number of coordinates this value has
Note that for all values besides vectors and psuedovectors, this is completely different than the dimension which instead measures the dimension of the space the value lives in.
- For blades, this value is equal to number of combinations of size
self.grade()
you can make fromself.dim()
basis vectors, iebinom(self.dim(), self.grade())
. - For even values, the number of elements is
2^(self.dim()-1)
with the exception of1
when the dimension is0
- For general multivectors, there are
2^self.dim()
components
Finally, note that in all cases, the value returned is either a compile-time constant or cached as the length of some array, so there is no computational overhead to this function.
Examples
let v = Vec4::from_element(0);
let b = BiVec4::from_element(0);
let r = Even4::from_element(0);
let m = Multivector4::from_element(0);
assert_eq!(v.elements(), 4); // (4 choose 1) = 4
assert_eq!(b.elements(), 6); // (4 choose 2) = 6
assert_eq!(r.elements(), 8); // 2^(4-1) = 8
assert_eq!(m.elements(), 16); // 2^4 = 16
Borrows the components of this value as a slice
The sum of squares of each element
Note that this does not take into account the conjugate of any complex elements. This is by explicit design:
- We can relax the
ComplexField
requirement and have more possibilies for scalars types (like polynomials!). - For vectors, this should give the quadradic form of the Clifford
algebra, but the function
Q(z) = zz̅
is not a valid quadradic form†
Trait Implementations
The default tolerance to use when testing values that are close together. Read more
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
The inverse of AbsDiffEq::abs_diff_eq
.
The default tolerance to use when testing values that are close together. Read more
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
The inverse of AbsDiffEq::abs_diff_eq
.
The default tolerance to use when testing values that are close together. Read more
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
The inverse of AbsDiffEq::abs_diff_eq
.
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
Performs the /=
operation. Read more
impl<'b, T1, T2, U, N: Dim> Mul<&'b Reflector<T2, N>> for Versor<T1, N> where
T1: AllocVersor<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocOdd<N>,
U: AllocVersor<N> + AddGroup,
impl<'b, T1, T2, U, N: Dim> Mul<&'b Reflector<T2, N>> for Versor<T1, N> where
T1: AllocVersor<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocOdd<N>,
U: AllocVersor<N> + AddGroup,
impl<'a, 'b, T1, T2, U, N: Dim> Mul<&'b Reflector<T2, N>> for &'a Versor<T1, N> where
T1: AllocVersor<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocOdd<N>,
U: AllocVersor<N> + AddGroup,
impl<'a, 'b, T1, T2, U, N: Dim> Mul<&'b Reflector<T2, N>> for &'a Versor<T1, N> where
T1: AllocVersor<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocOdd<N>,
U: AllocVersor<N> + AddGroup,
impl<'b, T1, T2, U, N: Dim> Mul<&'b Versor<T2, N>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocVersor<N>,
U: AllocVersor<N> + AddGroup,
impl<'b, T1, T2, U, N: Dim> Mul<&'b Versor<T2, N>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocVersor<N>,
U: AllocVersor<N> + AddGroup,
impl<'a, 'b, T1, T2, U, N: Dim> Mul<&'b Versor<T2, N>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocVersor<N>,
U: AllocVersor<N> + AddGroup,
impl<'a, 'b, T1, T2, U, N: Dim> Mul<&'b Versor<T2, N>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocVersor<N>,
U: AllocVersor<N> + AddGroup,
impl<T1, T2, U, N: Dim> Mul<Reflector<T2, N>> for Versor<T1, N> where
T1: AllocVersor<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocOdd<N>,
U: AllocVersor<N> + AddGroup,
impl<T1, T2, U, N: Dim> Mul<Reflector<T2, N>> for Versor<T1, N> where
T1: AllocVersor<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocOdd<N>,
U: AllocVersor<N> + AddGroup,
impl<'a, T1, T2, U, N: Dim> Mul<Reflector<T2, N>> for &'a Versor<T1, N> where
T1: AllocVersor<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocOdd<N>,
U: AllocVersor<N> + AddGroup,
impl<'a, T1, T2, U, N: Dim> Mul<Reflector<T2, N>> for &'a Versor<T1, N> where
T1: AllocVersor<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocOdd<N>,
U: AllocVersor<N> + AddGroup,
impl<T1, T2, U, N: Dim> Mul<Versor<T2, N>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocVersor<N>,
U: AllocVersor<N> + AddGroup,
impl<T1, T2, U, N: Dim> Mul<Versor<T2, N>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocVersor<N>,
U: AllocVersor<N> + AddGroup,
impl<'a, T1, T2, U, N: Dim> Mul<Versor<T2, N>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocVersor<N>,
U: AllocVersor<N> + AddGroup,
impl<'a, T1, T2, U, N: Dim> Mul<Versor<T2, N>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocVersor<N>,
U: AllocVersor<N> + AddGroup,
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
Performs the *=
operation. Read more
The default relative tolerance for testing values that are far-apart. Read more
A test for equality that uses a relative comparison if the values are far apart.
The inverse of RelativeEq::relative_eq
.
The default relative tolerance for testing values that are far-apart. Read more
A test for equality that uses a relative comparison if the values are far apart.
The inverse of RelativeEq::relative_eq
.
The default relative tolerance for testing values that are far-apart. Read more
A test for equality that uses a relative comparison if the values are far apart.
The inverse of RelativeEq::relative_eq
.
The default ULPs to tolerate when testing values that are far-apart. Read more
A test for equality that uses units in the last place (ULP) if the values are far apart.
The default ULPs to tolerate when testing values that are far-apart. Read more
A test for equality that uses units in the last place (ULP) if the values are far apart.
The default ULPs to tolerate when testing values that are far-apart. Read more
A test for equality that uses units in the last place (ULP) if the values are far apart.
impl<'b, T1, T2, U, N: Dim> VersorMul<&'b Multivector<T2, N>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocMultivector<N>,
U: AllocMultivector<N> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
impl<'b, T1, T2, U, N: Dim> VersorMul<&'b Multivector<T2, N>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocMultivector<N>,
U: AllocMultivector<N> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
type Output = Multivector<U, N>
impl<'a, 'b, T1, T2, U, N: Dim> VersorMul<&'b Multivector<T2, N>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocMultivector<N>,
U: AllocMultivector<N> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
impl<'a, 'b, T1, T2, U, N: Dim> VersorMul<&'b Multivector<T2, N>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocMultivector<N>,
U: AllocMultivector<N> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
type Output = Multivector<U, N>
impl<'b, T1, T2, U, N: Dim, G2: Dim> VersorMul<&'b SimpleBlade<T2, N, G2>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocBlade<N, G2>,
U: AllocBlade<N, G2> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
impl<'b, T1, T2, U, N: Dim, G2: Dim> VersorMul<&'b SimpleBlade<T2, N, G2>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocBlade<N, G2>,
U: AllocBlade<N, G2> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
type Output = SimpleBlade<U, N, G2>
impl<'a, 'b, T1, T2, U, N: Dim, G2: Dim> VersorMul<&'b SimpleBlade<T2, N, G2>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocBlade<N, G2>,
U: AllocBlade<N, G2> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
impl<'a, 'b, T1, T2, U, N: Dim, G2: Dim> VersorMul<&'b SimpleBlade<T2, N, G2>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocBlade<N, G2>,
U: AllocBlade<N, G2> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
type Output = SimpleBlade<U, N, G2>
impl<T1, T2, U, N: Dim> VersorMul<Multivector<T2, N>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocMultivector<N>,
U: AllocMultivector<N> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
impl<T1, T2, U, N: Dim> VersorMul<Multivector<T2, N>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocMultivector<N>,
U: AllocMultivector<N> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
type Output = Multivector<U, N>
impl<'a, T1, T2, U, N: Dim> VersorMul<Multivector<T2, N>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocMultivector<N>,
U: AllocMultivector<N> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
impl<'a, T1, T2, U, N: Dim> VersorMul<Multivector<T2, N>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocMultivector<N>,
U: AllocMultivector<N> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
type Output = Multivector<U, N>
impl<T1, T2, U, N: Dim, G2: Dim> VersorMul<SimpleBlade<T2, N, G2>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocBlade<N, G2>,
U: AllocBlade<N, G2> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
impl<T1, T2, U, N: Dim, G2: Dim> VersorMul<SimpleBlade<T2, N, G2>> for Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocBlade<N, G2>,
U: AllocBlade<N, G2> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
type Output = SimpleBlade<U, N, G2>
impl<'a, T1, T2, U, N: Dim, G2: Dim> VersorMul<SimpleBlade<T2, N, G2>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocBlade<N, G2>,
U: AllocBlade<N, G2> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
impl<'a, T1, T2, U, N: Dim, G2: Dim> VersorMul<SimpleBlade<T2, N, G2>> for &'a Reflector<T1, N> where
T1: AllocOdd<N> + AllRefMul<T2, AllOutput = U>,
T2: AllocBlade<N, G2>,
U: AllocBlade<N, G2> + for<'c> Mul<&'c T1, Output = U> + AddGroup,
type Output = SimpleBlade<U, N, G2>
Auto Trait Implementations
impl<T, N> RefUnwindSafe for Reflector<T, N> where
<T as AllocOdd<N>>::Buffer: RefUnwindSafe,
impl<T, N> UnwindSafe for Reflector<T, N> where
<T as AllocOdd<N>>::Buffer: UnwindSafe,
Blanket Implementations
type AllOutput = U
type AllOutput = U
type AllOutput = U
type AllOutput = U
type Buffer = DynBladeStorage<T, Const<N>, Dynamic>
type Buffer = DynBladeStorage<T, Dynamic, Const<G>>
type Buffer = DynBladeStorage<T, Dynamic, Dynamic>
type Buffer = DynMultivectorStorage<T, Dynamic>
Mutably borrows from an owned value. Read more
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.