Struct DVec2x2

Source
#[repr(C)]
pub struct DVec2x2 { pub x: f64x2, pub y: f64x2, }
Expand description

A set of two coordinates which may be interpreted as a vector or point in 2d space.

Generally this distinction between a point and vector is more of a pain than it is worth to distinguish on a type level, however when converting to and from homogeneous coordinates it is quite important.

Fields§

§x: f64x2§y: f64x2

Implementations§

Source§

impl DVec2x2

Source

pub const fn new(x: f64x2, y: f64x2) -> DVec2x2

Source

pub const fn broadcast(val: f64x2) -> DVec2x2

Source

pub fn unit_x() -> DVec2x2

Source

pub fn unit_y() -> DVec2x2

Source

pub fn into_homogeneous_point(self) -> DVec3x2

Create a homogeneous 2d point from this vector interpreted as a point, meaning the homogeneous component will start with a value of 1.0.

Source

pub fn into_homogeneous_vector(self) -> DVec3x2

Create a homogeneous 2d vector from this vector, meaning the homogeneous component will always have a value of 0.0.

Source

pub fn from_homogeneous_point(v: DVec3x2) -> DVec2x2

Create a 2d point from a homogeneous 2d point, performing division by the homogeneous component. This should not be used for homogeneous 2d vectors, which will have 0 as their homogeneous component.

Source

pub fn from_homogeneous_vector(v: DVec3x2) -> DVec2x2

Create a 2d vector from homogeneous 2d vector, which simply discards the homogeneous component.

Source

pub fn dot(&self, other: DVec2x2) -> f64x2

Source

pub fn wedge(&self, other: DVec2x2) -> DBivec2x2

The wedge (aka exterior) product of two vectors.

Note: Sometimes called “cross” product in 2D. Such a product is not well defined in 2 dimensions and is really just shorthand notation for a hacky operation that extends the vectors into 3 dimensions, takes the cross product, then returns only the resulting Z component as a pseudoscalar value. This value is will have the same value as the resulting bivector of the wedge product in 2d (a 2d bivector is also a kind of pseudoscalar value), so you may use this product to calculate the same value.

This operation results in a bivector, which represents the plane parallel to the two vectors, and which has a ‘oriented area’ equal to the parallelogram created by extending the two vectors, oriented such that the positive direction is the one which would move self closer to other.

Source

pub fn geom(&self, other: DVec2x2) -> DRotor2x2

The geometric product of this and another vector, which is defined as the sum of the dot product and the wedge product.

This operation results in a ‘rotor’, named as such as it may define a rotation. The rotor which results from the geometric product will rotate in the plane parallel to the two vectors, by twice the angle between them and in the opposite direction (i.e. it will rotate in the direction that would bring other towards self, and rotate in that direction by twice the angle between them).

Source

pub fn rotate_by(&mut self, rotor: DRotor2x2)

Source

pub fn rotated_by(self, rotor: DRotor2x2) -> DVec2x2

Source

pub fn reflected(&self, normal: DVec2x2) -> DVec2x2

Source

pub fn mag_sq(&self) -> f64x2

Source

pub fn mag(&self) -> f64x2

Source

pub fn normalize(&mut self)

Source

pub fn normalized(&self) -> DVec2x2

Source

pub fn mul_add(&self, mul: DVec2x2, add: DVec2x2) -> DVec2x2

Source

pub fn abs(&self) -> DVec2x2

Source

pub fn clamp(&mut self, min: DVec2x2, max: DVec2x2)

Source

pub fn clamped(self, min: DVec2x2, max: DVec2x2) -> DVec2x2

Source

pub fn map<F>(&self, f: F) -> DVec2x2
where F: FnMut(f64x2) -> f64x2,

Source

pub fn apply<F>(&mut self, f: F)
where F: FnMut(f64x2) -> f64x2,

Source

pub fn max_by_component(self, other: DVec2x2) -> DVec2x2

Source

pub fn min_by_component(self, other: DVec2x2) -> DVec2x2

Source

pub fn component_max(&self) -> f64x2

Source

pub fn component_min(&self) -> f64x2

Source

pub fn zero() -> DVec2x2

Source

pub fn one() -> DVec2x2

Source

pub fn xyz(&self) -> DVec3x2

Source

pub fn xyzw(&self) -> DVec4x2

Source

pub fn layout() -> Layout

Get the core::alloc::Layout of Self

Source

pub fn as_array(&self) -> &[f64x2; 2]

Interpret self as a statically-sized array of its base numeric type

Source

pub fn as_mut_array(&mut self) -> &mut [f64x2; 2]

Interpret self as a statically-sized array of its base numeric type

Source

pub fn as_slice(&self) -> &[f64x2]

Interpret self as a slice of its base numeric type

Source

pub fn as_mut_slice(&mut self) -> &mut [f64x2]

Interpret self as a slice of its base numeric type

Source

pub fn as_byte_slice(&self) -> &[u8]

Source

pub fn as_mut_byte_slice(&mut self) -> &mut [u8]

Source

pub const fn as_ptr(&self) -> *const f64x2

Returns a constant unsafe pointer to the underlying data in the underlying type. This function is safe because all types here are repr(C) and can be represented as their underlying type.

§Safety

It is up to the caller to correctly use this pointer and its bounds.

Source

pub fn as_mut_ptr(&mut self) -> *mut f64x2

Returns a mutable unsafe pointer to the underlying data in the underlying type. This function is safe because all types here are repr(C) and can be represented as their underlying type.

§Safety

It is up to the caller to correctly use this pointer and its bounds.

Source§

impl DVec2x2

Source

pub fn new_splat(x: f64, y: f64) -> DVec2x2

Source

pub fn splat(vec: DVec2) -> DVec2x2

Source

pub fn blend(mask: f64x2, tru: DVec2x2, fals: DVec2x2) -> DVec2x2

Blend two vectors together lanewise using mask as a mask.

This is essentially a bitwise blend operation, such that any point where there is a 1 bit in mask, the output will put the bit from tru, while where there is a 0 bit in mask, the output will put the bit from fals

Source

pub fn refract(&mut self, normal: DVec2x2, eta: f64x2)

Source

pub fn refracted(&self, normal: DVec2x2, eta: f64x2) -> DVec2x2

Trait Implementations§

Source§

impl Add for DVec2x2

Source§

type Output = DVec2x2

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for DVec2x2

Source§

fn add_assign(&mut self, rhs: DVec2x2)

Performs the += operation. Read more
Source§

impl Clone for DVec2x2

Source§

fn clone(&self) -> DVec2x2

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 DVec2x2

Source§

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

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

impl Default for DVec2x2

Source§

fn default() -> DVec2x2

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

impl Div<f64x2> for DVec2x2

Source§

type Output = DVec2x2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64x2) -> DVec2x2

Performs the / operation. Read more
Source§

impl Div for DVec2x2

Source§

type Output = DVec2x2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: DVec2x2) -> DVec2x2

Performs the / operation. Read more
Source§

impl DivAssign<f64x2> for DVec2x2

Source§

fn div_assign(&mut self, rhs: f64x2)

Performs the /= operation. Read more
Source§

impl DivAssign for DVec2x2

Source§

fn div_assign(&mut self, rhs: DVec2x2)

Performs the /= operation. Read more
Source§

impl FloatVector for DVec2x2

Source§

type Float = f64x2

Floating-point associated with the vector.
Source§

fn norm_squared(self) -> Self::Float

Returns the norm squared of the vector.
Source§

impl From<&[f64x2; 2]> for DVec2x2

Source§

fn from(comps: &[f64x2; 2]) -> DVec2x2

Converts to this type from the input type.
Source§

impl From<&(f64x2, f64x2)> for DVec2x2

Source§

fn from(comps: &(f64x2, f64x2)) -> DVec2x2

Converts to this type from the input type.
Source§

impl From<&mut [f64x2; 2]> for DVec2x2

Source§

fn from(comps: &mut [f64x2; 2]) -> DVec2x2

Converts to this type from the input type.
Source§

impl From<[DVec2; 2]> for DVec2x2

Source§

fn from(vecs: [DVec2; 2]) -> DVec2x2

Converts to this type from the input type.
Source§

impl From<[f64x2; 2]> for DVec2x2

Source§

fn from(comps: [f64x2; 2]) -> DVec2x2

Converts to this type from the input type.
Source§

impl From<(f64x2, f64x2)> for DVec2x2

Source§

fn from(comps: (f64x2, f64x2)) -> DVec2x2

Converts to this type from the input type.
Source§

impl From<DVec2> for DVec2x2

Source§

fn from(vec: DVec2) -> DVec2x2

Converts to this type from the input type.
Source§

impl From<DVec2x2> for DVec3x2

Source§

fn from(vec: DVec2x2) -> DVec3x2

Converts to this type from the input type.
Source§

impl From<DVec3x2> for DVec2x2

Source§

fn from(vec: DVec3x2) -> DVec2x2

Converts to this type from the input type.
Source§

impl Index<usize> for DVec2x2

Source§

type Output = f64x2

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &<DVec2x2 as Index<usize>>::Output

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

impl IndexMut<usize> for DVec2x2

Source§

fn index_mut(&mut self, index: usize) -> &mut <DVec2x2 as Index<usize>>::Output

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

impl IntoArray for DVec2x2

Source§

type Array = [f64x2; 2]

The array the type can be converted into.
Source§

impl Lerp<f64x2> for DVec2x2

Source§

fn lerp(&self, end: DVec2x2, t: f64x2) -> DVec2x2

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<DVec2x2> for f64x2

Source§

type Output = DVec2x2

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<f64x2> for DVec2x2

Source§

type Output = DVec2x2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64x2) -> DVec2x2

Performs the * operation. Read more
Source§

impl Mul for DVec2x2

Source§

type Output = DVec2x2

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign<f64x2> for DVec2x2

Source§

fn mul_assign(&mut self, rhs: f64x2)

Performs the *= operation. Read more
Source§

impl MulAssign for DVec2x2

Source§

fn mul_assign(&mut self, rhs: DVec2x2)

Performs the *= operation. Read more
Source§

impl Neg for DVec2x2

Source§

type Output = DVec2x2

The resulting type after applying the - operator.
Source§

fn neg(self) -> DVec2x2

Performs the unary - operation. Read more
Source§

impl PartialEq for DVec2x2

Source§

fn eq(&self, other: &DVec2x2) -> 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 Reduce for DVec2x2

Source§

fn reduce_sum(self) -> Self::Element

Sums the lanes of a SIMD vector.
Source§

impl SIMD for DVec2x2

Source§

type Element = DVec2

Element from which the SIMD value can be created.
Source§

type Lane = [<DVec2x2 as SIMD>::Element; 2]

The type a lane is equivalent to.
Source§

fn splat(element: Self::Element) -> Self

Creates a SIMD value with all lanes set to the specified value.
Source§

fn new_lane(lane: Self::Lane) -> Self

Creates a SIMD value with lanes set to the given values.
Source§

impl Slerp<f64x2> for DVec2x2

Source§

fn slerp(&self, end: DVec2x2, t: f64x2) -> DVec2x2

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 DVec2x2

Source§

type Output = DVec2x2

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for DVec2x2

Source§

fn sub_assign(&mut self, rhs: DVec2x2)

Performs the -= operation. Read more
Source§

impl Sum for DVec2x2

Source§

fn sum<I>(iter: I) -> DVec2x2
where I: Iterator<Item = DVec2x2>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Zero for DVec2x2

Source§

const ZERO: Self

zero value of the type.
Source§

impl Copy for DVec2x2

Source§

impl StructuralPartialEq for DVec2x2

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<U> AsPrimitive for U

Source§

fn as_<F: FromPrimitive<Self>>(self) -> F

Converts this primitive into the input primitive.
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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<F> FloatOps for F
where F: AddAssign + Sub<Output = F> + SubAssign + Mul<Output = F> + Add<Output = F> + MulAssign + Div<Output = F> + Neg<Output = F> + DivAssign,

Source§

impl<V, F> FloatVectorOps<F> for V
where V: Add<Output = V> + AddAssign + Sub<Output = V> + IntoArray + SubAssign + Mul<F, Output = V> + Sum + MulAssign<F> + Div<F, Output = V> + Neg<Output = V> + DivAssign<F>,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,