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

Represents a rotation in N dimensions

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.

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

Rotates the given input by self

Creates a new Rotor rotating in the plane of the input and by the angle given by its norm

Creates a new Rotor that rotates in the given plane by the given angle

Computes a bivector whos exponential is self

The result should be a bivector that is the sum of floor(N/2) simple bivectors with directions and magnitudes corresponding to the planes and angles of the simple rotations making up this Rotor.

Uniqueness

As with other non-real logarithms, the result of this function is not unique:

  • As with complex logarithms, an angle of can always be added in the direction of the output to get a result with the same exponential.
  • When self == -1 and N >= 3, there are infinitely many planes in which the rotation could have taken place, so an arbitrary choice is picked.
  • For isoclinic rotations (ie double rotations where both rotations have the same angle), the choice of rotation planes is also not unique, so again, an arbitrary choice is picked.

Raises this rotor to the power of a real number

Geometrically, this scales the angles of rotation of this rotor by t.

More concretely, this is calulated as x^t == exp(t*log(x)). As such, whenever log() makes an arbitrary choice for the rotation plane, this function does as well.

Smoothly interpolates the rotations of self and other

Concretely, this is computed as (other/self)^t * self

Creates a 2D rotation from an angle

Returns the angle of this Rotor’s rotation

Creates a 3D rotation about the given vector axis where the angle is the norm of the vector

Creates a 3D rotation about the given axis with the given angle

Returns the plane and angle of rotation or None if the angle is 0

Returns the plane of rotation scaled by the angle of rotation

Returns the axis and angle of rotation or None if the angle is 0

Returns the axis of rotation scaled by the angle of rotation

Returns both planes and both angles of rotation or None for either if they are 0

Returns both planes of rotation scaled by their angles of rotation

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

Methods from Deref<Target = Even<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 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

Always true, but useful for macros

Always false, but useful for macros

Determines if the dimension of two Evens 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.

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.

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 /= operation. Read more

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

Performs the *= operation. Read more

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.

Returns true if self is equal to the multiplicative identity. Read more

Sets self to the multiplicative identity element of Self, 1.

Returns the multiplicative identity element of Self, 1. Read more

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

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