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
Rotationcan only be multiplied with itself. - In contrast, the
ProperRotationand theImproperRotationcan be multiplied both with themselves and with each other.
Implementations§
Source§impl Rotation
impl Rotation
Sourcepub const fn mul(self, x: CubeSurfacePoint) -> CubeSurfacePoint
pub const fn mul(self, x: CubeSurfacePoint) -> CubeSurfacePoint
Because Mul is not const.
Trait Implementations§
Source§impl Div for Rotation
Implements division between rotations, such that
(rot_a * rot_b) / rot_b == rot_a.
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§impl From<CubeSurfacePoint<false>> for Rotation
impl From<CubeSurfacePoint<false>> for Rotation
Source§fn from(corresponding_point: CubeSurfacePoint<false>) -> Self
fn from(corresponding_point: CubeSurfacePoint<false>) -> Self
Source§impl From<CubeSurfacePoint<true>> for Rotation
impl From<CubeSurfacePoint<true>> for Rotation
Source§fn from(corresponding_point: CubeSurfacePoint<true>) -> Self
fn from(corresponding_point: CubeSurfacePoint<true>) -> Self
Source§impl From<CubeSurfacePoint> for Rotation
impl From<CubeSurfacePoint> for Rotation
Source§fn from(corresponding_point: CubeSurfacePoint) -> Self
fn from(corresponding_point: CubeSurfacePoint) -> Self
Source§impl From<ImproperRotation> for Rotation
Discards any notion of propriety, producing a general Rotation.
impl From<ImproperRotation> for Rotation
Discards any notion of propriety, producing a general Rotation.
Source§fn from(x: ImproperRotation) -> Self
fn from(x: ImproperRotation) -> Self
Source§impl From<ProperRotation> for Rotation
Discards any notion of propriety, producing a general Rotation.
impl From<ProperRotation> for Rotation
Discards any notion of propriety, producing a general Rotation.
Source§fn from(x: ProperRotation) -> Self
fn from(x: ProperRotation) -> Self
Source§impl From<Rotation> for CubeSurfacePoint
impl From<Rotation> for CubeSurfacePoint
Source§impl From<Rotation> for CubeSurfacePoint<false>
impl From<Rotation> for CubeSurfacePoint<false>
Source§impl From<Rotation> for CubeSurfacePoint<true>
impl From<Rotation> for CubeSurfacePoint<true>
Source§impl Mul<CubeSurfacePoint<false>> for Rotation
Rotates a copy of a given CubeSurfacePoint according to self.
impl Mul<CubeSurfacePoint<false>> for Rotation
Rotates a copy of a given CubeSurfacePoint according to self.
Source§impl Mul<CubeSurfacePoint<true>> for Rotation
Rotates a copy of a given CubeSurfacePoint according to self.
impl Mul<CubeSurfacePoint<true>> for Rotation
Rotates a copy of a given CubeSurfacePoint according to self.
Source§impl Mul<CubeSurfacePoint> for Rotation
Rotates a given CubeSurfacePoint according to self.
impl Mul<CubeSurfacePoint> for Rotation
Rotates a given CubeSurfacePoint according to self.
Source§type Output = CubeSurfacePoint
type Output = CubeSurfacePoint
Output same as input.
Source§fn mul(self, cub_sur_pt: CubeSurfacePoint) -> Self::Output
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.
impl Mul<Rotation> for CubeSurfacePoint
Rotates a copy of self per some Rotation.
Source§impl Mul<Rotation> for CubeSurfacePoint<false>
Rotates a copy of self according to a Rotation.
impl Mul<Rotation> for CubeSurfacePoint<false>
Rotates a copy of self according to a Rotation.
Source§type Output = CubeSurfacePoint<false>
type Output = CubeSurfacePoint<false>
We use the most general data-type possible, so the output does not change.
Source§impl Mul<Rotation> for CubeSurfacePoint<true>
Rotates a copy of self according to a Rotation.
impl Mul<Rotation> for CubeSurfacePoint<true>
Rotates a copy of self according to a Rotation.
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.
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§impl MulAssign<Rotation> for CubeSurfacePoint
Rotates self per some Rotation.
impl MulAssign<Rotation> for CubeSurfacePoint
Rotates self per some Rotation.
Source§fn mul_assign(&mut self, rot: Rotation)
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.
impl MulAssign<Rotation> for CubeSurfacePoint<false>
Rotates self according to a Rotation.
Source§fn mul_assign(&mut self, rot: Rotation)
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.
impl MulAssign<Rotation> for CubeSurfacePoint<true>
Rotates self according to a Rotation.
Source§fn mul_assign(&mut self, rot: Rotation)
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
impl Ord for Rotation
Source§impl PartialOrd for Rotation
impl PartialOrd for Rotation
Source§impl TryFrom<Rotation> for ImproperRotation
Discriminates a Rotation based on impropriety.
impl TryFrom<Rotation> for ImproperRotation
Discriminates a Rotation based on impropriety.
Source§impl TryFrom<Rotation> for ProperRotation
Discriminates a Rotation based on propriety.
impl TryFrom<Rotation> for ProperRotation
Discriminates a Rotation based on propriety.