Expand description
2D vector
Usually used as either a coordinate or a difference of coordinates, but may have some other uses.
Vectors are partially ordered and support component-wise comparison via
methods like lhs.lt(rhs). The PartialOrd trait is not implemented since
it implements lhs ≤ rhs as lhs < rhs || lhs == rhs which is wrong for
vectors (consider for lhs = (0, 1), rhs = (1, 0)).
Tuple Fields
0: f321: f32Implementations
sourceimpl Vec2
impl Vec2
sourcepub const NEG_INFINITY: Vec2 = _
pub const NEG_INFINITY: Vec2 = _
Negative infinity
sourcepub const fn splat(value: f32) -> Self
pub const fn splat(value: f32) -> Self
Constructs a new instance with each element initialized to value.
sourcepub fn complex_mul(self, rhs: Self) -> Self
pub fn complex_mul(self, rhs: Self) -> Self
Multiply two vectors as if they are complex numbers
sourcepub fn complex_div(self, rhs: Self) -> Self
pub fn complex_div(self, rhs: Self) -> Self
Divide by a second vector as if they are complex numbers
sourcepub fn complex_inv(self) -> Self
pub fn complex_inv(self) -> Self
Take the complex reciprocal
sourcepub fn sum_square(self) -> f32
pub fn sum_square(self) -> f32
Return the sum of the square of the terms
sourcepub fn extract<D: Directional>(self, dir: D) -> f32
pub fn extract<D: Directional>(self, dir: D) -> f32
Extract one component, based on a direction
This merely extracts the horizontal or vertical component. It never negates it, even if the axis is reversed.
Trait Implementations
sourceimpl AddAssign<Vec2> for Quad
impl AddAssign<Vec2> for Quad
sourcefn add_assign(&mut self, rhs: Vec2)
fn add_assign(&mut self, rhs: Vec2)
Performs the += operation. Read more
sourceimpl AddAssign<Vec2> for Vec2
impl AddAssign<Vec2> for Vec2
sourcefn add_assign(&mut self, rhs: Vec2)
fn add_assign(&mut self, rhs: Vec2)
Performs the += operation. Read more
sourceimpl AddAssign<f32> for Vec2
impl AddAssign<f32> for Vec2
sourcefn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
Performs the += operation. Read more
sourceimpl ConvApprox<DVec2> for Vec2
impl ConvApprox<DVec2> for Vec2
sourcefn try_conv_approx(size: DVec2) -> Result<Vec2>
fn try_conv_approx(size: DVec2) -> Result<Vec2>
Try converting from T to Self, allowing approximation of value Read more
sourcefn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
Converting from T to Self, allowing approximation of value Read more
sourceimpl ConvApprox<Vec2> for Coord
impl ConvApprox<Vec2> for Coord
sourcefn try_conv_approx(arg: Vec2) -> Result<Self>
fn try_conv_approx(arg: Vec2) -> Result<Self>
Try converting from T to Self, allowing approximation of value Read more
sourcefn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
Converting from T to Self, allowing approximation of value Read more
sourceimpl ConvApprox<Vec2> for Offset
impl ConvApprox<Vec2> for Offset
sourcefn try_conv_approx(arg: Vec2) -> Result<Self>
fn try_conv_approx(arg: Vec2) -> Result<Self>
Try converting from T to Self, allowing approximation of value Read more
sourcefn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
Converting from T to Self, allowing approximation of value Read more
sourceimpl ConvApprox<Vec2> for Size
impl ConvApprox<Vec2> for Size
sourcefn try_conv_approx(arg: Vec2) -> Result<Self>
fn try_conv_approx(arg: Vec2) -> Result<Self>
Try converting from T to Self, allowing approximation of value Read more
sourcefn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
Converting from T to Self, allowing approximation of value Read more
sourceimpl ConvFloat<Vec2> for Coord
impl ConvFloat<Vec2> for Coord
sourcefn try_conv_trunc(x: Vec2) -> Result<Self>
fn try_conv_trunc(x: Vec2) -> Result<Self>
Try converting to integer with truncation Read more
sourcefn try_conv_nearest(x: Vec2) -> Result<Self>
fn try_conv_nearest(x: Vec2) -> Result<Self>
Try converting to the nearest integer Read more
sourcefn try_conv_floor(x: Vec2) -> Result<Self>
fn try_conv_floor(x: Vec2) -> Result<Self>
Try converting the floor to an integer Read more
sourcefn try_conv_ceil(x: Vec2) -> Result<Self>
fn try_conv_ceil(x: Vec2) -> Result<Self>
Try convert the ceiling to an integer Read more
sourcefn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
Convert to integer with truncatation Read more
sourcefn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
Convert to the nearest integer Read more
sourcefn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
Convert the floor to an integer Read more
sourceimpl ConvFloat<Vec2> for Offset
impl ConvFloat<Vec2> for Offset
sourcefn try_conv_trunc(x: Vec2) -> Result<Self>
fn try_conv_trunc(x: Vec2) -> Result<Self>
Try converting to integer with truncation Read more
sourcefn try_conv_nearest(x: Vec2) -> Result<Self>
fn try_conv_nearest(x: Vec2) -> Result<Self>
Try converting to the nearest integer Read more
sourcefn try_conv_floor(x: Vec2) -> Result<Self>
fn try_conv_floor(x: Vec2) -> Result<Self>
Try converting the floor to an integer Read more
sourcefn try_conv_ceil(x: Vec2) -> Result<Self>
fn try_conv_ceil(x: Vec2) -> Result<Self>
Try convert the ceiling to an integer Read more
sourcefn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
Convert to integer with truncatation Read more
sourcefn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
Convert to the nearest integer Read more
sourcefn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
Convert the floor to an integer Read more
sourceimpl ConvFloat<Vec2> for Size
impl ConvFloat<Vec2> for Size
sourcefn try_conv_trunc(x: Vec2) -> Result<Self>
fn try_conv_trunc(x: Vec2) -> Result<Self>
Try converting to integer with truncation Read more
sourcefn try_conv_nearest(x: Vec2) -> Result<Self>
fn try_conv_nearest(x: Vec2) -> Result<Self>
Try converting to the nearest integer Read more
sourcefn try_conv_floor(x: Vec2) -> Result<Self>
fn try_conv_floor(x: Vec2) -> Result<Self>
Try converting the floor to an integer Read more
sourcefn try_conv_ceil(x: Vec2) -> Result<Self>
fn try_conv_ceil(x: Vec2) -> Result<Self>
Try convert the ceiling to an integer Read more
sourcefn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
Convert to integer with truncatation Read more
sourcefn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
Convert to the nearest integer Read more
sourcefn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
Convert the floor to an integer Read more
sourceimpl<'de> Deserialize<'de> for Vec2
impl<'de> Deserialize<'de> for Vec2
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<LogicalSize> for Vec2
impl From<LogicalSize> for Vec2
sourcefn from(LogicalSize: LogicalSize) -> Self
fn from(LogicalSize: LogicalSize) -> Self
Converts to this type from the input type.
sourceimpl From<Vec2> for LogicalSize
impl From<Vec2> for LogicalSize
sourceimpl PartialEq<Vec2> for Vec2
impl PartialEq<Vec2> for Vec2
sourceimpl SubAssign<Vec2> for Quad
impl SubAssign<Vec2> for Quad
sourcefn sub_assign(&mut self, rhs: Vec2)
fn sub_assign(&mut self, rhs: Vec2)
Performs the -= operation. Read more
sourceimpl SubAssign<Vec2> for Vec2
impl SubAssign<Vec2> for Vec2
sourcefn sub_assign(&mut self, rhs: Vec2)
fn sub_assign(&mut self, rhs: Vec2)
Performs the -= operation. Read more
sourceimpl SubAssign<f32> for Vec2
impl SubAssign<f32> for Vec2
sourcefn sub_assign(&mut self, rhs: f32)
fn sub_assign(&mut self, rhs: f32)
Performs the -= operation. Read more
impl Copy for Vec2
impl StructuralPartialEq for Vec2
Auto Trait Implementations
impl RefUnwindSafe for Vec2
impl Send for Vec2
impl Sync for Vec2
impl Unpin for Vec2
impl UnwindSafe for Vec2
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
sourcefn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Try approximate conversion from Self to T Read more
sourcefn cast_approx(self) -> T
fn cast_approx(self) -> T
Cast approximately from Self to T Read more
sourceimpl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
sourcefn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
sourcefn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
sourcefn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more
sourcefn try_cast_trunc(self) -> Result<T, Error>
fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
sourcefn try_cast_nearest(self) -> Result<T, Error>
fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
sourcefn try_cast_floor(self) -> Result<T, Error>
fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
sourcefn try_cast_ceil(self) -> Result<T, Error>
fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more
sourceimpl<S, T> ConvApprox<S> for Twhere
T: Conv<S>,
impl<S, T> ConvApprox<S> for Twhere
T: Conv<S>,
sourcefn try_conv_approx(x: S) -> Result<T, Error>
fn try_conv_approx(x: S) -> Result<T, Error>
Try converting from T to Self, allowing approximation of value Read more
sourcefn conv_approx(x: S) -> T
fn conv_approx(x: S) -> T
Converting from T to Self, allowing approximation of value Read more