Struct slender_math::Vector2f

source ·
#[repr(C, align(8))]
pub struct Vector2f(_);
Expand description

A vector with 2 f32 components

Implementations§

source§

impl Vector2f

source

pub const ZERO: Self = _

The vector (0, 0)

source

pub const ONE: Self = _

The vector (1, 1)

source

pub const UNIT_X: Self = _

The vector (1, 0)

source

pub const UNIT_Y: Self = _

The vector (0, 1)

source

pub const fn x(&self) -> f32

The x component of the vector

source

pub fn x_mut(&mut self) -> &mut f32

The x component of the vector

source

pub const fn y(&self) -> f32

The y component of the vector

source

pub fn y_mut(&mut self) -> &mut f32

The y component of the vector

source

pub const fn r(&self) -> f32

The r component of the vector

source

pub fn r_mut(&mut self) -> &mut f32

The r component of the vector

source

pub const fn g(&self) -> f32

The g component of the vector

source

pub fn g_mut(&mut self) -> &mut f32

The g component of the vector

source

pub const fn new(x: f32, y: f32) -> Self

Creates a new vector from the given components

source

pub const fn from_scalar(scalar: f32) -> Self

Creates a new vector by setting all components to the given scalar

source

pub const fn from_array(array: [f32; 2]) -> Self

Creates a new vector from the given array

source

pub const fn to_array(&self) -> [f32; 2]

Converts the vector into an array

source

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

Returns an array reference to the vector

source

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

Returns a mutable array reference to the vector

source

pub fn cross(self, rhs: Self) -> f32

Calculates the cross product between this vector and rhs by setting the Z components to 0 and returns the magnitude of the resulting vector

source§

impl Vector2f

source

pub fn abs(self) -> Self

Returns a vector with each component set to the absolute value of the corresponding component in this vector

source

pub fn recip(self) -> Self

Returns a vector with each component set to the reciprocal of the corresponding component in this vector

source

pub fn floor(self) -> Self

Returns a vector with each component set to the floor of the corresponding component in this vector

source

pub fn ceil(self) -> Self

Returns a vector with each component set to the ceiling of the corresponding component in this vector

source

pub fn fract(self) -> Self

Returns a vector with each component set to the fractional part of the corresponding component in this vector

source

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

Calculates the dot product between this vector and rhs

source

pub fn len2(self) -> f32

The length of this vector squared

source

pub fn len(self) -> f32

The length of this vector

source

pub fn normalized(self) -> Self

Normalizes the vector

source

pub fn lerp(self, rhs: Self, t: f32) -> Self

Linearily interpolates between this vector and rhs

source

pub fn dist2(self, b: Self) -> f32

Calculates the distance between this vector and rhs squared

source

pub fn dist(self, b: Self) -> f32

Calculates the distance between this vector and rhs

source

pub fn min(self, rhs: Self) -> Self

Returns a vector with each component set to the minimum of the corresponding components between this vector and rhs

source

pub fn max(self, rhs: Self) -> Self

Returns a vector with each component set to the maximum of the corresponding components between this vector and rhs

source

pub fn mul_add(self, a: Self, b: Self) -> Self

Calculates (self * a) + b in one operation

§

impl Vector2f

pub fn xx(&self) -> Vector2f

pub fn rr(&self) -> Vector2f

pub fn xy(&self) -> Vector2f

pub fn rg(&self) -> Vector2f

pub fn yx(&self) -> Vector2f

pub fn gr(&self) -> Vector2f

pub fn yy(&self) -> Vector2f

pub fn gg(&self) -> Vector2f

pub fn xxx(&self) -> Vector3f

pub fn rrr(&self) -> Vector3f

pub fn xxy(&self) -> Vector3f

pub fn rrg(&self) -> Vector3f

pub fn xyx(&self) -> Vector3f

pub fn rgr(&self) -> Vector3f

pub fn xyy(&self) -> Vector3f

pub fn rgg(&self) -> Vector3f

pub fn yxx(&self) -> Vector3f

pub fn grr(&self) -> Vector3f

pub fn yxy(&self) -> Vector3f

pub fn grg(&self) -> Vector3f

pub fn yyx(&self) -> Vector3f

pub fn ggr(&self) -> Vector3f

pub fn yyy(&self) -> Vector3f

pub fn ggg(&self) -> Vector3f

pub fn xxxx(&self) -> Vector4f

pub fn rrrr(&self) -> Vector4f

pub fn xxxy(&self) -> Vector4f

pub fn rrrg(&self) -> Vector4f

pub fn xxyx(&self) -> Vector4f

pub fn rrgr(&self) -> Vector4f

pub fn xxyy(&self) -> Vector4f

pub fn rrgg(&self) -> Vector4f

pub fn xyxx(&self) -> Vector4f

pub fn rgrr(&self) -> Vector4f

pub fn xyxy(&self) -> Vector4f

pub fn rgrg(&self) -> Vector4f

pub fn xyyx(&self) -> Vector4f

pub fn rggr(&self) -> Vector4f

pub fn xyyy(&self) -> Vector4f

pub fn rggg(&self) -> Vector4f

pub fn yxxx(&self) -> Vector4f

pub fn grrr(&self) -> Vector4f

pub fn yxxy(&self) -> Vector4f

pub fn grrg(&self) -> Vector4f

pub fn yxyx(&self) -> Vector4f

pub fn grgr(&self) -> Vector4f

pub fn yxyy(&self) -> Vector4f

pub fn grgg(&self) -> Vector4f

pub fn yyxx(&self) -> Vector4f

pub fn ggrr(&self) -> Vector4f

pub fn yyxy(&self) -> Vector4f

pub fn ggrg(&self) -> Vector4f

pub fn yyyx(&self) -> Vector4f

pub fn gggr(&self) -> Vector4f

pub fn yyyy(&self) -> Vector4f

pub fn gggg(&self) -> Vector4f

Trait Implementations§

source§

impl Add<Vector2f> for Vector2f

§

type Output = Vector2f

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add<f32> for Vector2f

§

type Output = Vector2f

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl AddAssign<Vector2f> for Vector2f

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl AddAssign<f32> for Vector2f

source§

fn add_assign(&mut self, rhs: f32)

Performs the += operation. Read more
source§

impl AsMut<[f32; 2]> for Vector2f

source§

fn as_mut(&mut self) -> &mut [f32; 2]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<[f32; 2]> for Vector2f

source§

fn as_ref(&self) -> &[f32; 2]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<[f32; 2]> for Vector2f

source§

fn borrow(&self) -> &[f32; 2]

Immutably borrows from an owned value. Read more
source§

impl BorrowMut<[f32; 2]> for Vector2f

source§

fn borrow_mut(&mut self) -> &mut [f32; 2]

Mutably borrows from an owned value. Read more
source§

impl Clone for Vector2f

source§

fn clone(&self) -> Vector2f

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 Vector2f

source§

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

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

impl Display for Vector2f

source§

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

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

impl Div<Vector2f> for Vector2f

§

type Output = Vector2f

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl Div<f32> for Vector2f

§

type Output = Vector2f

The resulting type after applying the / operator.
source§

fn div(self, rhs: f32) -> Self::Output

Performs the / operation. Read more
source§

impl DivAssign<Vector2f> for Vector2f

source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
source§

impl DivAssign<f32> for Vector2f

source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
source§

impl From<[f32; 2]> for Vector2f

source§

fn from(a: [f32; 2]) -> Self

Converts to this type from the input type.
source§

impl Index<usize> for Vector2f

§

type Output = f32

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

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

impl IndexMut<usize> for Vector2f

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

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

impl Into<[f32; 2]> for Vector2f

source§

fn into(self) -> [f32; 2]

Converts this type into the (usually inferred) input type.
source§

impl Mul<Vector2f> for Matrix2x3

§

type Output = Vector2f

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<Vector2f> for Vector2f

§

type Output = Vector2f

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<f32> for Vector2f

§

type Output = Vector2f

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl MulAssign<Vector2f> for Vector2f

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl MulAssign<f32> for Vector2f

source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
source§

impl Neg for Vector2f

§

type Output = Vector2f

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl PartialEq<Vector2f> for Vector2f

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Rem<Vector2f> for Vector2f

§

type Output = Vector2f

The resulting type after applying the % operator.
source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
source§

impl Rem<f32> for Vector2f

§

type Output = Vector2f

The resulting type after applying the % operator.
source§

fn rem(self, rhs: f32) -> Self::Output

Performs the % operation. Read more
source§

impl RemAssign<Vector2f> for Vector2f

source§

fn rem_assign(&mut self, rhs: Self)

Performs the %= operation. Read more
source§

impl RemAssign<f32> for Vector2f

source§

fn rem_assign(&mut self, rhs: f32)

Performs the %= operation. Read more
source§

impl Sub<Vector2f> for Vector2f

§

type Output = Vector2f

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Sub<f32> for Vector2f

§

type Output = Vector2f

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl SubAssign<Vector2f> for Vector2f

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl SubAssign<f32> for Vector2f

source§

fn sub_assign(&mut self, rhs: f32)

Performs the -= operation. Read more
source§

impl Zeroable for Vector2f

source§

fn zeroed() -> Self

source§

impl Copy for Vector2f

source§

impl Pod for Vector2f

source§

impl StructuralPartialEq for Vector2f

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CheckedBitPattern for Twhere T: AnyBitPattern,

§

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

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> AnyBitPattern for Twhere T: Pod,

source§

impl<T> NoUninit for Twhere T: Pod,