[go: up one dir, main page]

Struct DRotor2

Source
#[repr(C)]
pub struct DRotor2 { pub s: f64, pub bv: DBivec2, }
Expand description

A Rotor in 2d space.

Please see the module level documentation for more information on rotors!

Fields§

§s: f64§bv: DBivec2

Implementations§

Source§

impl DRotor2

Source

pub const fn new(scalar: f64, bivector: DBivec2) -> Self

Source

pub fn identity() -> Self

Source

pub fn from_rotation_between(from: DVec2, to: DVec2) -> Self

Construct a Rotor that rotates one vector to another.

A rotation between antiparallel vectors is undefined!

Source

pub fn from_angle_plane(angle: f64, plane: DBivec2) -> Self

Construct a rotor given a bivector which defines a plane and rotation orientation, and a rotation angle.

plane must be normalized!

This is the equivalent of an axis-angle rotation.

Source

pub fn from_angle(angle: f64) -> Self

Construct a rotor given only an angle. This is possible in 2d since there is only one possible plane of rotation. However, there are two possible orientations. This function uses the common definition of positive angle in 2d as meaning the direction which brings the x unit vector towards the y unit vector.

Source

pub fn mag_sq(&self) -> f64

Source

pub fn mag(&self) -> f64

Source

pub fn normalize(&mut self)

Source

pub fn normalized(&self) -> Self

Source

pub fn reverse(&mut self)

Source

pub fn reversed(&self) -> Self

Source

pub fn dot(&self, rhs: Self) -> f64

Source

pub fn rotate_by(&mut self, other: Self)

Rotates this rotor by another rotor in-place. Note that if you are looking to compose rotations, you should NOT use this operation and rather just use regular left-multiplication like for matrix composition.

Source

pub fn rotated_by(self, other: Self) -> Self

Rotates this rotor by another rotor and returns the result. Note that if you are looking to compose rotations, you should NOT use this operation and rather just use regular left-multiplication like for matrix composition.

Source

pub fn rotate_vec(self, vec: &mut DVec2)

Rotates a vector by this rotor.

self must be normalized!

Source

pub fn into_matrix(self) -> DMat2

Source

pub fn layout() -> Layout

Trait Implementations§

Source§

impl Add for DRotor2

Source§

type Output = DRotor2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl AddAssign for DRotor2

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for DRotor2

Source§

fn clone(&self) -> DRotor2

Returns a copy 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 DRotor2

Source§

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

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

impl Default for DRotor2

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Div<f64> for DRotor2

Source§

type Output = DRotor2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self

Performs the / operation. Read more
Source§

impl DivAssign<f64> for DRotor2

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl From<DRotor2> for DMat2

Source§

fn from(rotor: DRotor2) -> DMat2

Converts to this type from the input type.
Source§

impl Lerp<f64> for DRotor2

Source§

fn lerp(&self, end: Self, t: f64) -> Self

Linearly interpolate between self and end by t between 0.0 and 1.0. i.e. (1.0 - t) * self + (t) * end.

For interpolating Rotors with linear interpolation, you almost certainly want to normalize the returned Rotor. For example,

let interpolated_rotor = rotor1.lerp(rotor2, 0.5).normalized();

For most cases (especially where performance is the primary concern, like in animation interpolation for games, this ‘normalized lerp’ or ‘nlerp’ is probably what you want to use. However, there are situations in which you really want the interpolation between two Rotors to be of constant angular velocity. In this case, check out Slerp.

Source§

impl Mul<DIsometry2> for DRotor2

Source§

type Output = DIsometry2

The resulting type after applying the * operator.
Source§

fn mul(self, iso: DIsometry2) -> DIsometry2

Performs the * operation. Read more
Source§

impl Mul<DRotor2> for DIsometry2

Source§

type Output = DIsometry2

The resulting type after applying the * operator.
Source§

fn mul(self, rotor: DRotor2) -> DIsometry2

Performs the * operation. Read more
Source§

impl Mul<DRotor2> for DSimilarity2

Source§

type Output = DSimilarity2

The resulting type after applying the * operator.
Source§

fn mul(self, rotor: DRotor2) -> DSimilarity2

Performs the * operation. Read more
Source§

impl Mul<DRotor2> for f64

Source§

type Output = DRotor2

The resulting type after applying the * operator.
Source§

fn mul(self, rotor: DRotor2) -> DRotor2

Performs the * operation. Read more
Source§

impl Mul<DSimilarity2> for DRotor2

Source§

type Output = DSimilarity2

The resulting type after applying the * operator.
Source§

fn mul(self, iso: DSimilarity2) -> DSimilarity2

Performs the * operation. Read more
Source§

impl Mul<DVec2> for DRotor2

Source§

type Output = DVec2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DVec2) -> DVec2

Performs the * operation. Read more
Source§

impl Mul<f64> for DRotor2

Source§

type Output = DRotor2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self

Performs the * operation. Read more
Source§

impl Mul for DRotor2

The composition of self with q, i.e. self * q gives the rotation as though you first perform q and then self.

Source§

type Output = DRotor2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
Source§

impl MulAssign<f64> for DRotor2

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl PartialEq for DRotor2

Source§

fn eq(&self, other: &DRotor2) -> 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 Slerp<f64> for DRotor2

Source§

fn slerp(&self, end: Self, t: f64) -> Self

Spherical-linear interpolation between self and end based on t from 0.0 to 1.0.

self and end should both be normalized or something bad will happen!

The implementation for SIMD types also requires that the two things being interpolated between are not exactly aligned, or else the result is undefined.

Basically, interpolation that maintains a constant angular velocity from one orientation on a unit hypersphere to another. This is sorta the “high quality” interpolation for Rotors, and it can also be used to interpolate other things, one example being interpolation of 3d normal vectors.

Note that you should often normalize the result returned by this operation, when working with Rotors, etc!

Source§

impl Sub for DRotor2

Source§

type Output = DRotor2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl SubAssign for DRotor2

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Zeroable for DRotor2

Source§

fn zeroed() -> Self

Source§

impl Copy for DRotor2

Source§

impl Pod for DRotor2

Source§

impl StructuralPartialEq for DRotor2

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> NoUninit for T
where T: Pod,