Struct glamour::Vector2

source ·
#[repr(C)]
pub struct Vector2<T: Unit = f32> { pub x: T::Scalar, pub y: T::Scalar, }
Expand description

2D vector.

Bitwise compatible with glam::Vec2 / glam::DVec2 / glam::IVec2

Alignment: Same as the scalar.

Fields§

§x: T::Scalar

X coordinate

§y: T::Scalar

Y coordinate

Implementations§

source§

impl<T: Unit> Vector2<T>

source

pub const ZERO: Self = _

All zeroes.

source

pub const ONE: Self = _

All ones.

source

pub const X: Self = _

Unit vector in the direction of the X axis.

source

pub const Y: Self = _

Unit vector in the direction of the Y axis.

source

pub const AXES: [Self; 2] = _

The unit axes.

source

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

New vector.

source

pub fn from_array(array: [T::Scalar; 2]) -> Self

Instantiate from array. See glam::Vec2::from_array().

source

pub fn to_array(self) -> [T::Scalar; 2]

Convert to array. See glam::Vec2::to_array().

source

pub fn splat(scalar: T::Scalar) -> Self

Instance with all components set to scalar. See glam::Vec2::splat().

source

pub fn write_to_slice(self, slice: &mut [T::Scalar])

Write all components to slice.

source

pub fn cmpeq(self, other: Self) -> BVec2

Return a mask with the result of a component-wise equals comparison. See glam::Vec2::cmpeq().

source

pub fn cmpne(self, other: Self) -> BVec2

Return a mask with the result of a component-wise not-equal comparison. See glam::Vec2::cmpne().

source

pub fn cmpge(self, other: Self) -> BVec2

Return a mask with the result of a component-wise greater-than-or-equal comparison. See glam::Vec2::cmpge().

source

pub fn cmpgt(self, other: Self) -> BVec2

Return a mask with the result of a component-wise greater-than comparison. See glam::Vec2::cmpgt().

source

pub fn cmple(self, other: Self) -> BVec2

Return a mask with the result of a component-wise less-than-or-equal comparison. See glam::Vec2::cmple().

source

pub fn cmplt(self, other: Self) -> BVec2

Return a mask with the result of a component-wise less-than comparison. See glam::Vec2::cmplt().

source

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

Minimum by component. See glam::Vec2::min().

source

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

Maximum by component. See glam::Vec2::max().

source

pub fn min_element(self) -> T::Scalar

Horizontal minimum (smallest component). See glam::Vec2::min_element().

source

pub fn max_element(self) -> T::Scalar

Horizontal maximum (largest component). See glam::Vec2::max_element().

source

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

Component-wise clamp. See glam::Vec2::clamp().

source

pub fn select(mask: BVec2, a: Self, b: Self) -> Self

Select components from two instances based on a mask. See glam::Vec2::select().

source

pub fn from_untyped(untyped: Vector2<T::Scalar>) -> Vector2<T>

Bitcast an untyped instance to self.

source

pub fn to_untyped(self) -> Vector2<T::Scalar>

Bitcast self to an untyped instance.

source

pub fn as_untyped(&self) -> &Vector2<T::Scalar>

Reinterpret cast self as the untyped variant.

source

pub fn as_untyped_mut(&mut self) -> &mut Vector2<T::Scalar>

Reinterpret cast self as the untyped variant.

source

pub fn cast<T2>(self) -> Vector2<T2>
where T2: Unit<Scalar = T::Scalar>,

Cast to a different coordinate space with the same underlying scalar type.

source

pub fn cast_ref<T2>(&self) -> &Vector2<T2>
where T2: Unit<Scalar = T::Scalar>,

Cast to a different coordinate space with the same underlying scalar type.

source

pub fn cast_mut<T2>(&mut self) -> &mut Vector2<T2>
where T2: Unit<Scalar = T::Scalar>,

Cast to a different coordinate space with the same underlying scalar type.

source

pub fn try_cast<T2>(self) -> Option<Vector2<T2>>
where T2: Unit,

Cast to a different coordinate space with scalar type conversion. Returns None if any component could not be converted to the target scalar type.

source

pub const fn from_tuple((x, y): (T::Scalar, T::Scalar)) -> Self

Instantiate from tuple.

source

pub const fn to_tuple(self) -> (T::Scalar, T::Scalar)

Convert to tuple.

source

pub fn as_array(&self) -> &[T::Scalar; 2]

Reinterpret as array.

source

pub fn as_array_mut(&mut self) -> &mut [T::Scalar; 2]

Reinterpret as mutable array.

source

pub fn get(&self, index: usize) -> T::Scalar

Get component at index.

source

pub fn set(&mut self, index: usize, value: T::Scalar)

Set component at index.

source

pub fn const_get<const N: usize>(&self) -> T::Scalar

Get component at index N.

source

pub fn const_set<const N: usize>(&mut self, value: T::Scalar)

Set component at index N.

source

pub fn dot(self, other: Self) -> T::Scalar

Dot product See glam::Vec2::dot().

source

pub fn extend(self, z: T::Scalar) -> Vector3<T>

Extend with z-component to Vector3. See glam::Vec2::extend().

source

pub fn with_x(self, x: T::Scalar) -> Self

Replace the x-component with a new value. See glam::Vec2::with_x().

source

pub fn with_y(self, y: T::Scalar) -> Self

Replace the y-component with a new value. See glam::Vec2::with_y().

source

pub fn element_sum(self) -> T::Scalar

Returns the sum of all elements of self. See glam::Vec2::element_sum().

source

pub fn element_product(self) -> T::Scalar

Returns the product of all elements of self. See glam::Vec2::element_product().

source

pub fn swizzle<const X: usize, const Y: usize>(&self) -> Self

Select components of this vector and return a new vector containing those components.

source

pub fn from_point(point: Point2<T>) -> Self

Instantiate from point.

source

pub fn to_point(self) -> Point2<T>

Convert to point.

source

pub fn as_point(&self) -> &Point2<T>

Reinterpret as point.

source

pub fn as_point_mut(&mut self) -> &mut Point2<T>

Reinterpret as point.

source

pub fn from_size(size: Size2<T>) -> Self

Instantiate from size.

source

pub fn to_size(self) -> Size2<T>

Convert to size.

source

pub fn as_size(&self) -> &Size2<T>

Reinterpret as size.

source

pub fn as_size_mut(&mut self) -> &mut Size2<T>

Reinterpret as size.

source§

impl<T> Vector2<T>
where T: Unit, T::Scalar: FloatScalar,

source

pub const NAN: Self = _

All NaN.

source

pub const INFINITY: Self = _

All positive infinity.

source

pub const NEG_INFINITY: Self = _

All negative infinity.

source

pub fn is_finite(&self) -> bool

True if all components are non-infinity and non-NaN. See glam::Vec2::is_finite().

source

pub fn is_nan(&self) -> bool

True if any component is NaN. See glam::Vec2::is_nan().

source

pub fn is_nan_mask(&self) -> BVec2

Return a mask where each bit is set if the corresponding component is NaN. See glam::Vec2::is_nan_mask().

source

pub fn ceil(self) -> Self

Round all components up. See glam::Vec2::ceil().

source

pub fn floor(self) -> Self

Round all components down. See glam::Vec2::floor().

source

pub fn round(self) -> Self

Round all components. See glam::Vec2::round().

source

pub fn fract(self) -> Self

source

pub fn fract_gl(self) -> Self

source

pub fn lerp(self, other: Self, t: T::Scalar) -> Self

Linear interpolation. See glam::Vec2::lerp().

source

pub fn normalize(self) -> Self

Normalize the vector. Undefined results in the vector’s length is (very close to) zero. See glam::Vec2::normalize().

source

pub fn normalize_or_zero(self) -> Self

Normalize the vector, returning zero if the length was already (very close to) zero. See glam::Vec2::normalize_or_zero().

source

pub fn normalize_or(self, fallback: Self) -> Self

Returns self normalized to length 1.0 if possible, else returns a fallback value. See glam::Vec2::normalize_or().

source

pub fn try_normalize(self) -> Option<Self>

Normalize the vector, returning None if the length was already (very close to) zero. See glam::Vec2::try_normalize().

source

pub fn is_normalized(self) -> bool

True if the vector is normalized. See glam::Vec2::is_normalized().

source

pub fn length(self) -> T::Scalar

Length of the vector See glam::Vec2::length().

source

pub fn length_squared(self) -> T::Scalar

Squared length of the vector See glam::Vec2::length_squared().

source

pub fn length_recip(self) -> T::Scalar

Reciprocal length of the vector See glam::Vec2::length_recip().

source

pub fn exp(self) -> Self

e^self by component See glam::Vec2::exp().

source

pub fn powf(self, n: T::Scalar) -> Self

self^n by component See glam::Vec2::powf().

source

pub fn recip(self) -> Self

1.0/self by component See glam::Vec2::recip().

source

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

self * a + b See glam::Vec2::mul_add().

source

pub fn clamp_length(self, min: T::Scalar, max: T::Scalar) -> Self

Clamp length See glam::Vec2::clamp_length().

source

pub fn clamp_length_min(self, min: T::Scalar) -> Self

source

pub fn clamp_length_max(self, max: T::Scalar) -> Self

source

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

source

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

source

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

source

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

source

pub fn from_angle(angle: Angle<T::Scalar>) -> Vector2<T::Scalar>

Return (sin(angle), cos(angle). See glam::Vec2::from_angle().

source

pub fn rotate(self, rotation: Vector2<T::Scalar>) -> Self

Rotate by a vector containing (sin(angle), cos(angle)) See glam::Vec2::rotate().

source

pub fn to_angle(self) -> Angle<T::Scalar>

Returns the angle (in radians) of this vector in the range [-π, +π]. See glam::Vec2::to_angle().

source

pub fn angle_between(self, other: Self) -> Angle<T::Scalar>

Angle between this and another vector. See glam::Vec2::angle_between().

source§

impl<T> Vector2<T>
where T: Unit, T::Scalar: IntScalar,

source

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

Returns a vector containing the saturating addition of self and rhs. See glam::IVec2::saturating_add().

source

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

Returns a vector containing the saturating subtraction of self and rhs. See glam::IVec2::saturating_sub().

source

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

Returns a vector containing the saturating multiplication of self and rhs. See glam::IVec2::saturating_mul().

source

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

Returns a vector containing the saturating division of self and rhs. See glam::IVec2::saturating_div().

source

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

Returns a vector containing the wrapping addition of self and rhs. See glam::IVec2::wrapping_add().

source

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

Returns a vector containing the wrapping subtraction of self and rhs. See glam::IVec2::wrapping_sub().

source

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

Returns a vector containing the wrapping multiplication of self and rhs. See glam::IVec2::wrapping_mul().

source

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

Returns a vector containing the wrapping division of self and rhs. See glam::IVec2::wrapping_div().

source§

impl<T> Vector2<T>
where T: Unit, T::Scalar: SignedScalar,

source

pub const NEG_ONE: Self = _

All negative one.

source

pub const NEG_X: Self = _

(-1, 0)

source

pub const NEG_Y: Self = _

(0, -1)

source

pub fn abs(self) -> Self

Turn all components positive. See glam::Vec2::abs().

source

pub fn signum(self) -> Self

Return a vector where each component is 1 or -1 depending on the sign of the input. See glam::Vec2::signum().

source

pub fn perp(self) -> Self

Get the perpendicular vector. See glam::Vec2::perp().

source

pub fn perp_dot(self, other: Self) -> T::Scalar

Perpendicular dot product See glam::Vec2::perp_dot().

Trait Implementations§

source§

impl<T: Unit> AbsDiffEq for Vector2<T>

§

type Epsilon = <<T as Unit>::Scalar as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
source§

fn abs_diff_ne(&self, other: &Self, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
source§

impl<T: Unit> Add<Vector2<T>> for Box2<T>

§

type Output = Box2<T>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T: Unit> Add<Vector2<T>> for Point2<T>

§

type Output = Point2<T>

The resulting type after applying the + operator.
source§

fn add(self, other: Vector2<T>) -> Self

Performs the + operation. Read more
source§

impl<T: Unit> Add for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T: Unit> AddAssign<Vector2<T>> for Box2<T>

source§

fn add_assign(&mut self, rhs: Vector2<T>)

Performs the += operation. Read more
source§

impl<T: Unit> AddAssign<Vector2<T>> for Point2<T>

source§

fn add_assign(&mut self, other: Vector2<T>)

Performs the += operation. Read more
source§

impl<T: Unit<Scalar = f32>> AddAssign<f32> for Vector2<T>

source§

fn add_assign(&mut self, other: f32)

Performs the += operation. Read more
source§

impl<T: Unit<Scalar = f64>> AddAssign<f64> for Vector2<T>

source§

fn add_assign(&mut self, other: f64)

Performs the += operation. Read more
source§

impl<T: Unit<Scalar = i32>> AddAssign<i32> for Vector2<T>

source§

fn add_assign(&mut self, other: i32)

Performs the += operation. Read more
source§

impl<T: Unit<Scalar = u32>> AddAssign<u32> for Vector2<T>

source§

fn add_assign(&mut self, other: u32)

Performs the += operation. Read more
source§

impl<T: Unit> AddAssign for Vector2<T>

source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
source§

impl<T: Unit> AsMut<[<T as Unit>::Scalar]> for Vector2<T>

source§

fn as_mut(&mut self) -> &mut [T::Scalar]

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

impl<T: Unit> AsMut<[<T as Unit>::Scalar; 2]> for Vector2<T>

source§

fn as_mut(&mut self) -> &mut [T::Scalar; 2]

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

impl<T> AsMut<DVec2> for Vector2<T>
where T: Unit<Scalar = f64>,

source§

fn as_mut(&mut self) -> &mut DVec2

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

impl<T> AsMut<I64Vec2> for Vector2<T>
where T: Unit<Scalar = i64>,

source§

fn as_mut(&mut self) -> &mut I64Vec2

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

impl<T> AsMut<IVec2> for Vector2<T>
where T: Unit<Scalar = i32>,

source§

fn as_mut(&mut self) -> &mut IVec2

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

impl<T> AsMut<U64Vec2> for Vector2<T>
where T: Unit<Scalar = u64>,

source§

fn as_mut(&mut self) -> &mut U64Vec2

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

impl<T> AsMut<UVec2> for Vector2<T>
where T: Unit<Scalar = u32>,

source§

fn as_mut(&mut self) -> &mut UVec2

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

impl<T> AsMut<Vec2> for Vector2<T>
where T: Unit<Scalar = f32>,

source§

fn as_mut(&mut self) -> &mut Vec2

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

impl<T: Unit> AsRaw for Vector2<T>

source§

fn as_raw(&self) -> &Self::Raw

By-ref conversion to Self::Raw.
source§

fn as_raw_mut(&mut self) -> &mut Self::Raw

By-ref mutable conversion to Self::Raw.
source§

impl<T: Unit> AsRef<[<T as Unit>::Scalar]> for Vector2<T>

source§

fn as_ref(&self) -> &[T::Scalar]

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

impl<T: Unit> AsRef<[<T as Unit>::Scalar; 2]> for Vector2<T>

source§

fn as_ref(&self) -> &[T::Scalar; 2]

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

impl<T> AsRef<DVec2> for Vector2<T>
where T: Unit<Scalar = f64>,

source§

fn as_ref(&self) -> &DVec2

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

impl<T> AsRef<I64Vec2> for Vector2<T>
where T: Unit<Scalar = i64>,

source§

fn as_ref(&self) -> &I64Vec2

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

impl<T> AsRef<IVec2> for Vector2<T>
where T: Unit<Scalar = i32>,

source§

fn as_ref(&self) -> &IVec2

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

impl<T> AsRef<U64Vec2> for Vector2<T>
where T: Unit<Scalar = u64>,

source§

fn as_ref(&self) -> &U64Vec2

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

impl<T> AsRef<UVec2> for Vector2<T>
where T: Unit<Scalar = u32>,

source§

fn as_ref(&self) -> &UVec2

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

impl<T> AsRef<Vec2> for Vector2<T>
where T: Unit<Scalar = f32>,

source§

fn as_ref(&self) -> &Vec2

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

impl<T> Borrow<DVec2> for Vector2<T>
where T: Unit<Scalar = f64>,

source§

fn borrow(&self) -> &DVec2

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<I64Vec2> for Vector2<T>
where T: Unit<Scalar = i64>,

source§

fn borrow(&self) -> &I64Vec2

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<IVec2> for Vector2<T>
where T: Unit<Scalar = i32>,

source§

fn borrow(&self) -> &IVec2

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<U64Vec2> for Vector2<T>
where T: Unit<Scalar = u64>,

source§

fn borrow(&self) -> &U64Vec2

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<UVec2> for Vector2<T>
where T: Unit<Scalar = u32>,

source§

fn borrow(&self) -> &UVec2

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<Vec2> for Vector2<T>
where T: Unit<Scalar = f32>,

source§

fn borrow(&self) -> &Vec2

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<Vector2<T>> for DVec2
where T: Unit<Scalar = f64>,

source§

fn borrow(&self) -> &Vector2<T>

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<Vector2<T>> for I64Vec2
where T: Unit<Scalar = i64>,

source§

fn borrow(&self) -> &Vector2<T>

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<Vector2<T>> for IVec2
where T: Unit<Scalar = i32>,

source§

fn borrow(&self) -> &Vector2<T>

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<Vector2<T>> for U64Vec2
where T: Unit<Scalar = u64>,

source§

fn borrow(&self) -> &Vector2<T>

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<Vector2<T>> for UVec2
where T: Unit<Scalar = u32>,

source§

fn borrow(&self) -> &Vector2<T>

Immutably borrows from an owned value. Read more
source§

impl<T> Borrow<Vector2<T>> for Vec2
where T: Unit<Scalar = f32>,

source§

fn borrow(&self) -> &Vector2<T>

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<DVec2> for Vector2<T>
where T: Unit<Scalar = f64>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<I64Vec2> for Vector2<T>
where T: Unit<Scalar = i64>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<IVec2> for Vector2<T>
where T: Unit<Scalar = i32>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<U64Vec2> for Vector2<T>
where T: Unit<Scalar = u64>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<UVec2> for Vector2<T>
where T: Unit<Scalar = u32>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<Vec2> for Vector2<T>
where T: Unit<Scalar = f32>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<Vector2<T>> for DVec2
where T: Unit<Scalar = f64>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<Vector2<T>> for I64Vec2
where T: Unit<Scalar = i64>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<Vector2<T>> for IVec2
where T: Unit<Scalar = i32>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<Vector2<T>> for U64Vec2
where T: Unit<Scalar = u64>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<Vector2<T>> for UVec2
where T: Unit<Scalar = u32>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<Vector2<T>> for Vec2
where T: Unit<Scalar = f32>,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T: Unit> Clone for Vector2<T>

source§

fn clone(&self) -> Self

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<T: Unit> Debug for Vector2<T>

source§

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

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

impl<T: Unit> Default for Vector2<T>

source§

fn default() -> Self

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

impl<T: Unit<Scalar = f32>> Div<f32> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the / operator.
source§

fn div(self, other: f32) -> Self

Performs the / operation. Read more
source§

impl<T: Unit<Scalar = f64>> Div<f64> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<T: Unit<Scalar = i32>> Div<i32> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the / operator.
source§

fn div(self, other: i32) -> Self

Performs the / operation. Read more
source§

impl<T: Unit<Scalar = u32>> Div<u32> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the / operator.
source§

fn div(self, other: u32) -> Self

Performs the / operation. Read more
source§

impl<T: Unit> Div for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<T: Unit<Scalar = f32>> DivAssign<f32> for Vector2<T>

source§

fn div_assign(&mut self, other: f32)

Performs the /= operation. Read more
source§

impl<T: Unit<Scalar = f64>> DivAssign<f64> for Vector2<T>

source§

fn div_assign(&mut self, other: f64)

Performs the /= operation. Read more
source§

impl<T: Unit<Scalar = i32>> DivAssign<i32> for Vector2<T>

source§

fn div_assign(&mut self, other: i32)

Performs the /= operation. Read more
source§

impl<T: Unit<Scalar = u32>> DivAssign<u32> for Vector2<T>

source§

fn div_assign(&mut self, other: u32)

Performs the /= operation. Read more
source§

impl<T: Unit> DivAssign for Vector2<T>

source§

fn div_assign(&mut self, other: Self)

Performs the /= operation. Read more
source§

impl<T: Unit> From<[<T as Unit>::Scalar; 2]> for Vector2<T>

source§

fn from(arr: [T::Scalar; 2]) -> Self

Converts to this type from the input type.
source§

impl<T: Unit> From<(<T as Unit>::Scalar, <T as Unit>::Scalar)> for Vector2<T>

source§

fn from(tuple: (T::Scalar, T::Scalar)) -> Vector2<T>

Converts to this type from the input type.
source§

impl<T: Unit> From<BVec2> for Vector2<T>

source§

fn from(v: BVec2) -> Self

Converts to this type from the input type.
source§

impl<T> From<DVec2> for Vector2<T>
where T: Unit<Scalar = f64>,

source§

fn from(vec: DVec2) -> Vector2<T>

Converts to this type from the input type.
source§

impl<T> From<I64Vec2> for Vector2<T>
where T: Unit<Scalar = i64>,

source§

fn from(vec: I64Vec2) -> Vector2<T>

Converts to this type from the input type.
source§

impl<T> From<IVec2> for Vector2<T>
where T: Unit<Scalar = i32>,

source§

fn from(vec: IVec2) -> Vector2<T>

Converts to this type from the input type.
source§

impl<T: Unit> From<Point2<T>> for Vector2<T>

source§

fn from(point: Point2<T>) -> Vector2<T>

Converts to this type from the input type.
source§

impl<T: Unit> From<Size2<T>> for Vector2<T>

source§

fn from(point: Size2<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<U64Vec2> for Vector2<T>
where T: Unit<Scalar = u64>,

source§

fn from(vec: U64Vec2) -> Vector2<T>

Converts to this type from the input type.
source§

impl<T> From<UVec2> for Vector2<T>
where T: Unit<Scalar = u32>,

source§

fn from(vec: UVec2) -> Vector2<T>

Converts to this type from the input type.
source§

impl<T> From<Vec2> for Vector2<T>
where T: Unit<Scalar = f32>,

source§

fn from(vec: Vec2) -> Vector2<T>

Converts to this type from the input type.
source§

impl<T: Unit> From<Vector2<T>> for [T::Scalar; 2]

source§

fn from(v: Vector2<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Unit> From<Vector2<T>> for (T::Scalar, T::Scalar)

source§

fn from(value: Vector2<T>) -> (T::Scalar, T::Scalar)

Converts to this type from the input type.
source§

impl<T> From<Vector2<T>> for DVec2
where T: Unit<Scalar = f64>,

source§

fn from(vec: Vector2<T>) -> DVec2

Converts to this type from the input type.
source§

impl<T> From<Vector2<T>> for I64Vec2
where T: Unit<Scalar = i64>,

source§

fn from(vec: Vector2<T>) -> I64Vec2

Converts to this type from the input type.
source§

impl<T> From<Vector2<T>> for IVec2
where T: Unit<Scalar = i32>,

source§

fn from(vec: Vector2<T>) -> IVec2

Converts to this type from the input type.
source§

impl<T: Unit> From<Vector2<T>> for Point2<T>

source§

fn from(vec: Vector2<T>) -> Point2<T>

Converts to this type from the input type.
source§

impl<T: Unit> From<Vector2<T>> for Size2<T>

source§

fn from(vec: Vector2<T>) -> Self

Converts to this type from the input type.
source§

impl<T> From<Vector2<T>> for U64Vec2
where T: Unit<Scalar = u64>,

source§

fn from(vec: Vector2<T>) -> U64Vec2

Converts to this type from the input type.
source§

impl<T> From<Vector2<T>> for UVec2
where T: Unit<Scalar = u32>,

source§

fn from(vec: Vector2<T>) -> UVec2

Converts to this type from the input type.
source§

impl<T> From<Vector2<T>> for Vec2
where T: Unit<Scalar = f32>,

source§

fn from(vec: Vector2<T>) -> Vec2

Converts to this type from the input type.
source§

impl<T: Unit> FromRaw for Vector2<T>

source§

fn from_raw(raw: Self::Raw) -> Self

By-value conversion from Self::Raw.
source§

impl<T> Hash for Vector2<T>
where T: Unit, T::Scalar: Hash,

source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: Unit> Index<usize> for Vector2<T>

§

type Output = <T as Unit>::Scalar

The returned type after indexing.
source§

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

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

impl<T: Unit> IndexMut<usize> for Vector2<T>

source§

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

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

impl<T: Unit> IntoIterator for Vector2<T>

§

type Item = <T as Unit>::Scalar

The type of the elements being iterated over.
§

type IntoIter = <[<T as Unit>::Scalar; 2] as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> Mul<Vector2<T>> for Matrix2<T::Scalar>
where T: FloatScalar,

§

type Output = Vector2<T>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vector2<T>) -> Vector2<T>

Performs the * operation. Read more
source§

impl<T: Unit<Scalar = f32>> Mul<f32> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the * operator.
source§

fn mul(self, other: f32) -> Self

Performs the * operation. Read more
source§

impl<T: Unit<Scalar = f64>> Mul<f64> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T: Unit<Scalar = i32>> Mul<i32> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the * operator.
source§

fn mul(self, other: i32) -> Self

Performs the * operation. Read more
source§

impl<T: Unit<Scalar = u32>> Mul<u32> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the * operator.
source§

fn mul(self, other: u32) -> Self

Performs the * operation. Read more
source§

impl<T: Unit> Mul for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T: Unit<Scalar = f32>> MulAssign<f32> for Vector2<T>

source§

fn mul_assign(&mut self, other: f32)

Performs the *= operation. Read more
source§

impl<T: Unit<Scalar = f64>> MulAssign<f64> for Vector2<T>

source§

fn mul_assign(&mut self, other: f64)

Performs the *= operation. Read more
source§

impl<T: Unit<Scalar = i32>> MulAssign<i32> for Vector2<T>

source§

fn mul_assign(&mut self, other: i32)

Performs the *= operation. Read more
source§

impl<T: Unit<Scalar = u32>> MulAssign<u32> for Vector2<T>

source§

fn mul_assign(&mut self, other: u32)

Performs the *= operation. Read more
source§

impl<T: Unit> MulAssign for Vector2<T>

source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
source§

impl<T> Neg for Vector2<T>
where T: Unit, T::Scalar: SignedScalar,

§

type Output = Vector2<T>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl<T: Unit> PartialEq<[<T as Unit>::Scalar; 2]> for Vector2<T>

source§

fn eq(&self, other: &[T::Scalar; 2]) -> 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<T: Unit> PartialEq<(<T as Unit>::Scalar, <T as Unit>::Scalar)> for Vector2<T>

source§

fn eq(&self, (x, y): &(T::Scalar, T::Scalar)) -> 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<T: Unit> PartialEq for Vector2<T>

source§

fn eq(&self, other: &Self) -> 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<'a, T: Unit> Product<&'a Vector2<T>> for Vector2<T>

source§

fn product<I>(iter: I) -> Self
where I: Iterator<Item = &'a Self>,

Method which takes an iterator and generates Self from the elements by multiplying the items.
source§

impl<T: Unit> RelativeEq for Vector2<T>
where T::Scalar: RelativeEq,

source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
source§

fn relative_ne( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of RelativeEq::relative_eq.
source§

impl<T: Unit<Scalar = f32>> Rem<f32> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the % operator.
source§

fn rem(self, other: f32) -> Self

Performs the % operation. Read more
source§

impl<T: Unit<Scalar = f64>> Rem<f64> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the % operator.
source§

fn rem(self, other: f64) -> Self

Performs the % operation. Read more
source§

impl<T: Unit<Scalar = i32>> Rem<i32> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the % operator.
source§

fn rem(self, other: i32) -> Self

Performs the % operation. Read more
source§

impl<T: Unit<Scalar = u32>> Rem<u32> for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the % operator.
source§

fn rem(self, other: u32) -> Self

Performs the % operation. Read more
source§

impl<T: Unit> Rem for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the % operator.
source§

fn rem(self, other: Self) -> Self

Performs the % operation. Read more
source§

impl<T: Unit<Scalar = f32>> RemAssign<f32> for Vector2<T>

source§

fn rem_assign(&mut self, other: f32)

Performs the %= operation. Read more
source§

impl<T: Unit<Scalar = f64>> RemAssign<f64> for Vector2<T>

source§

fn rem_assign(&mut self, other: f64)

Performs the %= operation. Read more
source§

impl<T: Unit<Scalar = i32>> RemAssign<i32> for Vector2<T>

source§

fn rem_assign(&mut self, other: i32)

Performs the %= operation. Read more
source§

impl<T: Unit<Scalar = u32>> RemAssign<u32> for Vector2<T>

source§

fn rem_assign(&mut self, other: u32)

Performs the %= operation. Read more
source§

impl<T: Unit> RemAssign for Vector2<T>

source§

fn rem_assign(&mut self, other: Self)

Performs the %= operation. Read more
source§

impl<T: Unit> Sub<Vector2<T>> for Box2<T>

§

type Output = Box2<T>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T: Unit> Sub<Vector2<T>> for Point2<T>

§

type Output = Point2<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: Vector2<T>) -> Self

Performs the - operation. Read more
source§

impl<T: Unit> Sub for Vector2<T>

§

type Output = Vector2<T>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T: Unit> SubAssign<Vector2<T>> for Box2<T>

source§

fn sub_assign(&mut self, rhs: Vector2<T>)

Performs the -= operation. Read more
source§

impl<T: Unit> SubAssign<Vector2<T>> for Point2<T>

source§

fn sub_assign(&mut self, other: Vector2<T>)

Performs the -= operation. Read more
source§

impl<T: Unit<Scalar = f32>> SubAssign<f32> for Vector2<T>

source§

fn sub_assign(&mut self, other: f32)

Performs the -= operation. Read more
source§

impl<T: Unit<Scalar = f64>> SubAssign<f64> for Vector2<T>

source§

fn sub_assign(&mut self, other: f64)

Performs the -= operation. Read more
source§

impl<T: Unit<Scalar = i32>> SubAssign<i32> for Vector2<T>

source§

fn sub_assign(&mut self, other: i32)

Performs the -= operation. Read more
source§

impl<T: Unit<Scalar = u32>> SubAssign<u32> for Vector2<T>

source§

fn sub_assign(&mut self, other: u32)

Performs the -= operation. Read more
source§

impl<T: Unit> SubAssign for Vector2<T>

source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
source§

impl<'a, T: Unit> Sum<&'a Vector2<T>> for Vector2<T>

source§

fn sum<I>(iter: I) -> Self
where I: Iterator<Item = &'a Self>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl<T: Unit> Swizzle<T> for Vector2<T>

source§

fn swizzle2<const X: usize, const Y: usize>(&self) -> Vector2<T>

Select two components from this vector and return a 2D vector made from those components.
source§

fn swizzle3<const X: usize, const Y: usize, const Z: usize>(&self) -> Vector3<T>

Select three components from this vector and return a 3D vector made from those components.
source§

fn swizzle4<const X: usize, const Y: usize, const Z: usize, const W: usize>( &self ) -> Vector4<T>

Select four components from this vector and return a 4D vector made from those components.
source§

impl<T: Unit> ToRaw for Vector2<T>

§

type Raw = <<T as Unit>::Scalar as Scalar>::Vec2

The underlying glam type.
source§

fn to_raw(self) -> Self::Raw

By-value conversion to Self::Raw.
source§

impl<Src, Dst> TransformMap<Vector2<Src>> for Transform2<Src, Dst>
where Src: Unit, Src::Scalar: FloatScalar, Dst: Unit<Scalar = Src::Scalar>,

§

type Output = Vector2<Dst>

Result type of the transformation.
source§

fn map(&self, value: Vector2<Src>) -> Self::Output

Map T to Self::Output.
source§

impl<T: Unit> TransparentWrapper<<<T as Unit>::Scalar as Scalar>::Vec2> for Vector2<T>

SAFETY: These are guaranteed to have the same representation.

source§

fn wrap(s: Inner) -> Self
where Self: Sized,

Convert the inner type into the wrapper type.
source§

fn wrap_ref(s: &Inner) -> &Self

Convert a reference to the inner type into a reference to the wrapper type.
source§

fn wrap_mut(s: &mut Inner) -> &mut Self

Convert a mutable reference to the inner type into a mutable reference to the wrapper type.
source§

fn wrap_slice(s: &[Inner]) -> &[Self]
where Self: Sized,

Convert a slice to the inner type into a slice to the wrapper type.
source§

fn wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]
where Self: Sized,

Convert a mutable slice to the inner type into a mutable slice to the wrapper type.
source§

fn peel(s: Self) -> Inner
where Self: Sized,

Convert the wrapper type into the inner type.
source§

fn peel_ref(s: &Self) -> &Inner

Convert a reference to the wrapper type into a reference to the inner type.
source§

fn peel_mut(s: &mut Self) -> &mut Inner

Convert a mutable reference to the wrapper type into a mutable reference to the inner type.
source§

fn peel_slice(s: &[Self]) -> &[Inner]
where Self: Sized,

Convert a slice to the wrapped type into a slice to the inner type.
source§

fn peel_slice_mut(s: &mut [Self]) -> &mut [Inner]
where Self: Sized,

Convert a mutable slice to the wrapped type into a mutable slice to the inner type.
source§

impl<T: Unit> UlpsEq for Vector2<T>
where T::Scalar: UlpsEq,

source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
source§

fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of UlpsEq::ulps_eq.
source§

impl<T: Unit> Zeroable for Vector2<T>

SAFETY: T::Scalar is Zeroable, and Vector2 is #[repr(C)].

source§

fn zeroed() -> Self

source§

impl<T: Unit> Copy for Vector2<T>

source§

impl<T> Eq for Vector2<T>
where T: Unit, T::Scalar: Eq,

source§

impl<T: Unit> Pod for Vector2<T>

SAFETY: T::Scalar is Pod.

Auto Trait Implementations§

§

impl<T> Freeze for Vector2<T>
where <T as Unit>::Scalar: Freeze,

§

impl<T> RefUnwindSafe for Vector2<T>
where <T as Unit>::Scalar: RefUnwindSafe,

§

impl<T> Send for Vector2<T>

§

impl<T> Sync for Vector2<T>

§

impl<T> Unpin for Vector2<T>
where <T as Unit>::Scalar: Unpin,

§

impl<T> UnwindSafe for Vector2<T>
where <T as Unit>::Scalar: UnwindSafe,

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,

§

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

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,

§

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>,

§

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>,

§

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,

source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

source§

impl<T> PodValue for T
where T: Copy + Debug + Default + PartialEq + Pod + Send + Sync + Serializable + 'static,

source§

impl<T> Serializable for T