#[repr(transparent)]
pub struct UnitBlade<T: AllocBlade<N, G>, N: Dim, G: Dim> { /* private fields */ }
Expand description

A SimpleBlade with unit length

Primary use is to represent oriented vector spaces of dimension G. If the quantity is going to be stored/cached for an extended period of time, this can also provide an optimization over a SimpleBlade since the length does not have to be accounted for.

Implementations

Returns the ith basis element or panics if i is out of range

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.

Reverses the order of the vectors in each basis blade

Negates self of each component with an odd grade

The multiplicative inverse of this element

Finds the parallel component of b onto self

Reflects about self

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

Embeds self into a different dimension by either removing elements or inserting zeros

Finds the dual of this unit blade. See Blade::dual() for more information

Finds the inverse dual of this unit blade. See Blade::undual() for more information

Returns the unit psuedoscalar in dimension N

Methods from Deref<Target = Blade<T, N, G>>

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

Returns the grade of this Blade as an instance of the generic type G

This is mostly used internally to unify the codebase between Const grades and Dynamic grades. Since Dynamic grades often require a usize input when Const grades do not, this allows a function to take a ZST for static Blades 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 grade of this blade

This describes the “dimension” of the vector space this blade represents. Note that this is completely different that the dimension of the blade which describes the the dimension of the surrounding space the blade lives in.

More concretely, the grade is the number of vector basis elements multiplied together to get a basis of this blade. So to get a blade of grade 3, you would need to wedge three vectors together.

Examples

//All vectors are grade 1
let v1 = Vec3::new(6, 2, 8);
let v2 = Vec6::new(6, 2, 8, 3, 1, 8);
let v3 = VecD::from_element(2, 0.0);

assert_eq!(v1.grade(), 1);
assert_eq!(v2.grade(), 1);
assert_eq!(v3.grade(), 1);

//All Bivectors are grade 2
let b1 = BiVec4::new(6, 2, 8, 3, 1, 8);
let b2 = BiVecD::from_element(3, 0.0);

assert_eq!(b1.grade(), 2);
assert_eq!(b2.grade(), 2);

//Dynamic blades
let blade1 = Blade6::from_element(5, 0.0);
let blade2 = BladeD::from_element(4, 3, 0.0);

assert_eq!(blade1.grade(), 5);
assert_eq!(blade2.grade(), 3);

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 from self.dim() basis vectors, ie binom(self.dim(), self.grade()).
  • For even values, the number of elements is 2^(self.dim()-1) with the exception of 1 when the dimension is 0
  • 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

Creates an iterator over references of each component

True if the grade if this blade is even

True if the grade if this blade is odd

True if blades if this grade square to positive numbers

True if blades if this grade square to negative numbers

Determines if the dimension and grade of two Blades are equal

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:

  1. We can relax the ComplexField requirement and have more possibilies for scalars types (like polynomials!).
  2. For vectors, this should give the quadradic form of the Clifford algebra, but the function Q(z) = zz̅ is not a valid quadradic form

The square root of the sum of squares of each element

As with norm_squared, this does not take into account the complex conjugate even though ComplexField is a requirement.

Finds the parallel component of b onto self

Finds the perpendicular component of b onto self

Reflects about self

Trait Implementations

Used for specifying relative comparisons.

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.

Used for specifying relative comparisons.

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.

Used for specifying relative comparisons.

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.

Used for specifying relative comparisons.

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.

Used for specifying relative comparisons.

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

Performs the conversion.

Formats the value using the given formatter.

Immutably borrows from an owned value. Read more

Immutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Performs the /= operation. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The result after applying the operator.

Returns the multiplicative inverse of self. Read more

The result after applying the operator.

Returns the multiplicative inverse of self. Read more

Formats the value using the given formatter.

Formats the value using the given formatter.

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

Performs the *= operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

Formats the value using the given formatter.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Method which takes an iterator and generates Self from the elements by multiplying the items. Read more

Method which takes an iterator and generates Self from the elements by multiplying the items. 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 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 inverse of UlpsEq::ulps_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 inverse of UlpsEq::ulps_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 inverse of UlpsEq::ulps_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 inverse of UlpsEq::ulps_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 inverse of UlpsEq::ulps_eq.

Formats the value using the given formatter.

Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.