#[repr(C)]pub struct Vec2(pub f32, pub f32);
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: f32
§1: f32
Implementations§
source§impl Vec2
impl Vec2
sourcepub const NEG_INFINITY: Vec2 = _
pub const NEG_INFINITY: Vec2 = _
Negative infinity
sourcepub const fn splat(value: f32) -> Vec2
pub const fn splat(value: f32) -> Vec2
Constructs a new instance with each element initialized to value
.
sourcepub fn complex_mul(self, rhs: Vec2) -> Vec2
pub fn complex_mul(self, rhs: Vec2) -> Vec2
Multiply two vectors as if they are complex numbers
sourcepub fn complex_div(self, rhs: Vec2) -> Vec2
pub fn complex_div(self, rhs: Vec2) -> Vec2
Divide by a second vector as if they are complex numbers
sourcepub fn complex_inv(self) -> Vec2
pub fn complex_inv(self) -> Vec2
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>(self, dir: D) -> f32where
D: Directional,
pub fn extract<D>(self, dir: D) -> f32where
D: Directional,
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§
source§impl AddAssign<Vec2> for Quad
impl AddAssign<Vec2> for Quad
source§fn add_assign(&mut self, rhs: Vec2)
fn add_assign(&mut self, rhs: Vec2)
+=
operation. Read moresource§impl AddAssign<f32> for Vec2
impl AddAssign<f32> for Vec2
source§fn add_assign(&mut self, rhs: f32)
fn add_assign(&mut self, rhs: f32)
+=
operation. Read moresource§impl AddAssign for Vec2
impl AddAssign for Vec2
source§fn add_assign(&mut self, rhs: Vec2)
fn add_assign(&mut self, rhs: Vec2)
+=
operation. Read moresource§impl ConvApprox<DVec2> for Vec2
impl ConvApprox<DVec2> for Vec2
source§impl ConvApprox<Vec2> for Coord
impl ConvApprox<Vec2> for Coord
source§impl ConvApprox<Vec2> for Offset
impl ConvApprox<Vec2> for Offset
source§impl ConvApprox<Vec2> for Size
impl ConvApprox<Vec2> for Size
source§impl ConvFloat<Vec2> for Coord
impl ConvFloat<Vec2> for Coord
source§fn try_conv_trunc(x: Vec2) -> Result<Coord, Error>
fn try_conv_trunc(x: Vec2) -> Result<Coord, Error>
source§fn try_conv_nearest(x: Vec2) -> Result<Coord, Error>
fn try_conv_nearest(x: Vec2) -> Result<Coord, Error>
source§fn try_conv_floor(x: Vec2) -> Result<Coord, Error>
fn try_conv_floor(x: Vec2) -> Result<Coord, Error>
source§fn try_conv_ceil(x: Vec2) -> Result<Coord, Error>
fn try_conv_ceil(x: Vec2) -> Result<Coord, Error>
§fn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
§fn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
§fn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
source§impl ConvFloat<Vec2> for Offset
impl ConvFloat<Vec2> for Offset
source§fn try_conv_trunc(x: Vec2) -> Result<Offset, Error>
fn try_conv_trunc(x: Vec2) -> Result<Offset, Error>
source§fn try_conv_nearest(x: Vec2) -> Result<Offset, Error>
fn try_conv_nearest(x: Vec2) -> Result<Offset, Error>
source§fn try_conv_floor(x: Vec2) -> Result<Offset, Error>
fn try_conv_floor(x: Vec2) -> Result<Offset, Error>
source§fn try_conv_ceil(x: Vec2) -> Result<Offset, Error>
fn try_conv_ceil(x: Vec2) -> Result<Offset, Error>
§fn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
§fn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
§fn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
source§impl ConvFloat<Vec2> for Size
impl ConvFloat<Vec2> for Size
source§fn try_conv_trunc(x: Vec2) -> Result<Size, Error>
fn try_conv_trunc(x: Vec2) -> Result<Size, Error>
source§fn try_conv_nearest(x: Vec2) -> Result<Size, Error>
fn try_conv_nearest(x: Vec2) -> Result<Size, Error>
source§fn try_conv_floor(x: Vec2) -> Result<Size, Error>
fn try_conv_floor(x: Vec2) -> Result<Size, Error>
source§fn try_conv_ceil(x: Vec2) -> Result<Size, Error>
fn try_conv_ceil(x: Vec2) -> Result<Size, Error>
§fn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
§fn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
§fn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
source§impl From<LogicalSize> for Vec2
impl From<LogicalSize> for Vec2
source§fn from(_: LogicalSize) -> Vec2
fn from(_: LogicalSize) -> Vec2
source§impl From<Vec2> for LogicalSize
impl From<Vec2> for LogicalSize
source§fn from(_: Vec2) -> LogicalSize
fn from(_: Vec2) -> LogicalSize
source§impl PartialEq for Vec2
impl PartialEq for Vec2
source§impl SubAssign<Vec2> for Quad
impl SubAssign<Vec2> for Quad
source§fn sub_assign(&mut self, rhs: Vec2)
fn sub_assign(&mut self, rhs: Vec2)
-=
operation. Read moresource§impl SubAssign<f32> for Vec2
impl SubAssign<f32> for Vec2
source§fn sub_assign(&mut self, rhs: f32)
fn sub_assign(&mut self, rhs: f32)
-=
operation. Read moresource§impl SubAssign for Vec2
impl SubAssign for Vec2
source§fn sub_assign(&mut self, rhs: Vec2)
fn sub_assign(&mut self, rhs: Vec2)
-=
operation. Read moreimpl 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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
§fn cast_approx(self) -> T
fn cast_approx(self) -> T
§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
§fn cast_floor(self) -> T
fn cast_floor(self) -> T
§fn try_cast_trunc(self) -> Result<T, Error>
fn try_cast_trunc(self) -> Result<T, Error>
§fn try_cast_nearest(self) -> Result<T, Error>
fn try_cast_nearest(self) -> Result<T, Error>
§fn try_cast_floor(self) -> Result<T, Error>
fn try_cast_floor(self) -> Result<T, Error>
§fn try_cast_ceil(self) -> Result<T, Error>
fn try_cast_ceil(self) -> Result<T, Error>
§impl<S, T> ConvApprox<S> for Twhere
T: Conv<S>,
impl<S, T> ConvApprox<S> for Twhere
T: Conv<S>,
§fn try_conv_approx(x: S) -> Result<T, Error>
fn try_conv_approx(x: S) -> Result<T, Error>
§fn conv_approx(x: S) -> T
fn conv_approx(x: S) -> T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.