Rotation

Struct Rotation 

Source
pub struct Rotation { /* private fields */ }
Expand description

A data-type that describes, within 6 bits, the transformation from one CubeSurfacePoint to another.

§Usage

let rotation = ending_point / beginning_point;
assert_eq!(beginning_point * rotation, ending_point);

§Representation

For a complete correspondence between arithmetic values and geometric transformations, please refer to the documentation for CubeSurfacePoint. In here, we will describe the correspondence of each transformation with its binary representation.

The gist is that the three first bits describe the order in which the three coördinates must be positioned, while the last three bits describe which of their signs have to be flipped. It must be noted that the bits cannot be examined in arbitrary order: Bit 3 must always be examined first, and the three last bits must be examined last. Their order and meaning is as follows:

  • 3: Swaps coöordinates 1 and 3.
  • 4: Swaps coöordinates 2 and 3.
  • 5: Swaps coöordinates 1 and 2.
  • 2: Flips the sign of coördinate 1.
  • 1: Flips the sign of coördinate 2.
  • 0: Flips the sign of coördinate 3.

Also note that this data-type encodes both proper and improper rotations. The ProperRotation and ImproperRotation data-types separate the two.

§Multiplying/dividing rotations together

The various rotation data-types can be multiplied, and therefore have had Mul and Div implemented between them:

  • The ordinary Rotation can only be multiplied with itself.
  • In contrast, the ProperRotation and the ImproperRotation can be multiplied both with themselves and with each other.

Implementations§

Source§

impl Rotation

Source

pub const fn mul(self, x: CubeSurfacePoint) -> CubeSurfacePoint

Because Mul is not const.

Trait Implementations§

Source§

impl Clone for Rotation

Source§

fn clone(&self) -> Rotation

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Rotation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Div for Rotation

Implements division between rotations, such that (rot_a * rot_b) / rot_b == rot_a.

Important note: rot_a / rot_b is not necessarily equal to (1 / rot_b) * rot_a. See also the relevant comment on Mul.

Source§

type Output = Rotation

The output type tells us all we know about the propriety of the result.

Source§

fn div(self, other: Rotation) -> Self::Output

Implemented by dividing the two corresponding points with one another.

Source§

impl From<CubeSurfacePoint<false>> for Rotation

Source§

fn from(corresponding_point: CubeSurfacePoint<false>) -> Self

Converts to this type from the input type.
Source§

impl From<CubeSurfacePoint<true>> for Rotation

Source§

fn from(corresponding_point: CubeSurfacePoint<true>) -> Self

Converts to this type from the input type.
Source§

impl From<CubeSurfacePoint> for Rotation

Source§

fn from(corresponding_point: CubeSurfacePoint) -> Self

Converts to this type from the input type.
Source§

impl From<ImproperRotation> for Rotation

Discards any notion of propriety, producing a general Rotation.

Source§

fn from(x: ImproperRotation) -> Self

Converts to this type from the input type.
Source§

impl From<ProperRotation> for Rotation

Discards any notion of propriety, producing a general Rotation.

Source§

fn from(x: ProperRotation) -> Self

Converts to this type from the input type.
Source§

impl From<Rotation> for CubeSurfacePoint

Source§

fn from(x: Rotation) -> Self

Converts to this type from the input type.
Source§

impl From<Rotation> for CubeSurfacePoint<false>

Source§

fn from(x: Rotation) -> Self

Converts to this type from the input type.
Source§

impl From<Rotation> for CubeSurfacePoint<true>

Source§

fn from(x: Rotation) -> Self

Converts to this type from the input type.
Source§

impl Mul<CubeSurfacePoint<false>> for Rotation

Rotates a copy of a given CubeSurfacePoint according to self.

Source§

type Output = CubeSurfacePoint<false>

Output same as input.

Source§

fn mul(self, cub_sur_pt: Self::Output) -> Self::Output

The rotation happens Elementary-Reflection-by-Elementary-Reflection as usual, but each Elementary Reflection is performed with a LUT.

Source§

impl Mul<CubeSurfacePoint<true>> for Rotation

Rotates a copy of a given CubeSurfacePoint according to self.

Source§

type Output = CubeSurfacePoint<true>

Output same as input.

Source§

fn mul(self, cub_sur_pt: Self::Output) -> Self::Output

self is not examined bit-by-bit. Instead, a look-up on a 2-D LUT produces the result directly.

Source§

impl Mul<CubeSurfacePoint> for Rotation

Rotates a given CubeSurfacePoint according to self.

Source§

type Output = CubeSurfacePoint

Output same as input.

Source§

fn mul(self, cub_sur_pt: CubeSurfacePoint) -> Self::Output

The operation is performed by examining self’s bits one by one, and performing on the other surface_point the corresponding elementary reflections.

Source§

impl Mul<Rotation> for CubeSurfacePoint

Rotates a copy of self per some Rotation.

Source§

type Output = CubeSurfacePoint

Output same as input.

Source§

fn mul(self, rot: Rotation) -> Self::Output

The operation is performed by examining the bits of the Rotation one-by-one, then performing the corresponding elementary reflections on self.

Source§

impl Mul<Rotation> for CubeSurfacePoint<false>

Rotates a copy of self according to a Rotation.

Source§

type Output = CubeSurfacePoint<false>

We use the most general data-type possible, so the output does not change.

Source§

fn mul(self, rot: Rotation) -> Self::Output

The rotation happens Elementary-Reflection-by-Elementary-Reflection as usual, but each Elementary Reflection is performed with a LUT.

Source§

impl Mul<Rotation> for CubeSurfacePoint<true>

Rotates a copy of self according to a Rotation.

Source§

type Output = CubeSurfacePoint<true>

We use the most general data-type possible, so the output does not change.

Source§

fn mul(self, rot: Rotation) -> Self::Output

The Rotation is not examined bit-by-bit. Instead, a look-up on a 2-D LUT produces the result directly.

Source§

impl Mul for Rotation

Implements multiplication between rotations, such that rot_a * rot_b * point_x can be computed as either rot_a * (rot_b * point_x) or (rot_a * rot_b) * point_x, with no change to the result computed.

Important note: Rotations are essentially highly simplified matrices. This means that, in the general case, commutativity does not hold, and therefore rot_a * rot_b and rot_b * rot_a are not necessarily equal.

Source§

type Output = Rotation

The output type tells us all we know about the propriety of the result.

Source§

fn mul(self, other: Rotation) -> Self::Output

Implemented by multiplying the second rotation’s corresponding point with the first one.

Source§

impl MulAssign<Rotation> for CubeSurfacePoint

Rotates self per some Rotation.

Source§

fn mul_assign(&mut self, rot: Rotation)

The data-type doesn’t change, so the result can be directly assigned.

Source§

impl MulAssign<Rotation> for CubeSurfacePoint<false>

Rotates self according to a Rotation.

Source§

fn mul_assign(&mut self, rot: Rotation)

We use the most general data-type possible, so the output does not change. Thus, it can be directly assigned.

The rotation happens Elementary-Reflection-by-Elementary-Reflection as usual, but each Elementary Reflection is performed with a LUT.

Source§

impl MulAssign<Rotation> for CubeSurfacePoint<true>

Rotates self according to a Rotation.

Source§

fn mul_assign(&mut self, rot: Rotation)

We use the most general data-type possible, so the output does not change. Thus, it can be directly assigned.

The Rotation is not examined bit-by-bit. Instead, a look-up on a 2-D LUT produces the result directly.

Source§

impl Ord for Rotation

Source§

fn cmp(&self, other: &Rotation) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Rotation

Source§

fn eq(&self, other: &Rotation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Rotation

Source§

fn partial_cmp(&self, other: &Rotation) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryFrom<Rotation> for ImproperRotation

Discriminates a Rotation based on impropriety.

Source§

type Error = ProperRotation

If a Rotation is not improper, it must by necessity be proper.

Source§

fn try_from(x: Rotation) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Rotation> for ProperRotation

Discriminates a Rotation based on propriety.

Source§

type Error = ImproperRotation

If a Rotation is not proper, it must by necessity be improper.

Source§

fn try_from(x: Rotation) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Rotation

Source§

impl Eq for Rotation

Source§

impl StructuralPartialEq for Rotation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.