#[repr(transparent)]pub struct IVec2(_);
Expand description
A 2-dimensional vector.
Implementations
sourceimpl IVec2
impl IVec2
sourcepub const X: IVec2 = Self(XYI32::X)
pub const X: IVec2 = Self(XYI32::X)
[1, 0]
: a unit-length vector pointing along the positive X axis.
sourcepub const Y: IVec2 = Self(XYI32::Y)
pub const Y: IVec2 = Self(XYI32::Y)
[0, 1]
: a unit-length vector pointing along the positive Y axis.
sourcepub const fn unit_x() -> IVec2
👎 Deprecated: Use Vec2::X instead
pub const fn unit_x() -> IVec2
Use Vec2::X instead
Creates a vector with values [x: 1.0, y: 0.0]
.
sourcepub const fn unit_y() -> IVec2
👎 Deprecated: Use Vec2::Y instead
pub const fn unit_y() -> IVec2
Use Vec2::Y instead
Creates a vector with values [x: 0.0, y: 1.0]
.
sourcepub const fn zero() -> IVec2
👎 Deprecated: use ZERO constant instead
pub const fn zero() -> IVec2
use ZERO constant instead
Creates a vector with all elements set to 0.0
.
sourcepub const fn one() -> IVec2
👎 Deprecated: use ONE constant instead
pub const fn one() -> IVec2
use ONE constant instead
Creates a vector with all elements set to 1.0
.
sourcepub fn select(mask: BVec2, if_true: IVec2, if_false: IVec2) -> IVec2
pub fn select(mask: BVec2, if_true: IVec2, if_false: IVec2) -> IVec2
Creates a vector from the elements in if_true
and if_false
, selecting which to use
for each element of self
.
A true element in the mask uses the corresponding element from if_true
, and false
uses the element from if_false
.
sourcepub fn min(self, other: IVec2) -> IVec2
pub fn min(self, other: IVec2) -> IVec2
Returns a vector containing the mininum values for each element of self
and other
.
In other words this computes [self.x.max(other.x), self.y.max(other.y), ..]
.
sourcepub fn max(self, other: IVec2) -> IVec2
pub fn max(self, other: IVec2) -> IVec2
Returns a vector containing the maximum values for each element of self
and other
.
In other words this computes [self.x.max(other.x), self.y.max(other.y), ..]
.
sourcepub fn clamp(self, min: IVec2, max: IVec2) -> IVec2
pub fn clamp(self, min: IVec2, max: IVec2) -> IVec2
Component-wise clamping of values, similar to [std::f32::clamp
].
Each element in min
must be less-or-equal to the corresponing element in max
.
If the glam-assert
feature is enabled, the function will panic if the contract is not
met, otherwise the behavior is undefined.
sourcepub fn min_element(self) -> i32
pub fn min_element(self) -> i32
Returns the horizontal minimum of self
.
In other words this computes min(x, y, ..)
.
sourcepub fn max_element(self) -> i32
pub fn max_element(self) -> i32
Returns the horizontal maximum of self
.
In other words this computes max(x, y, ..)
.
sourcepub fn cmpeq(self, other: IVec2) -> BVec2
pub fn cmpeq(self, other: IVec2) -> BVec2
Returns a vector mask containing the result of a ==
comparison for each element of
self
and other
.
In other words, this computes [self.x == other.x, self.y == other.y, ..]
for all
elements.
sourcepub fn cmpne(self, other: IVec2) -> BVec2
pub fn cmpne(self, other: IVec2) -> BVec2
Returns a vector mask containing the result of a !=
comparison for each element of
self
and other
.
In other words this computes [self.x != other.x, self.y != other.y, ..]
for all
elements.
sourcepub fn cmpge(self, other: IVec2) -> BVec2
pub fn cmpge(self, other: IVec2) -> BVec2
Returns a vector mask containing the result of a >=
comparison for each element of
self
and other
.
In other words this computes [self.x >= other.x, self.y >= other.y, ..]
for all
elements.
sourcepub fn cmpgt(self, other: IVec2) -> BVec2
pub fn cmpgt(self, other: IVec2) -> BVec2
Returns a vector mask containing the result of a >
comparison for each element of
self
and other
.
In other words this computes [self.x > other.x, self.y > other.y, ..]
for all
elements.
sourcepub fn cmple(self, other: IVec2) -> BVec2
pub fn cmple(self, other: IVec2) -> BVec2
Returns a vector mask containing the result of a <=
comparison for each element of
self
and other
.
In other words this computes [self.x <= other.x, self.y <= other.y, ..]
for all
elements.
sourcepub fn cmplt(self, other: IVec2) -> BVec2
pub fn cmplt(self, other: IVec2) -> BVec2
Returns a vector mask containing the result of a <
comparison for each element of
self
and other
.
In other words this computes [self.x < other.x, self.y < other.y, ..]
for all
elements.
sourcepub fn from_slice_unaligned(slice: &[i32]) -> IVec2
pub fn from_slice_unaligned(slice: &[i32]) -> IVec2
Creates a vector from the first N values in slice
.
Panics
Panics if slice
is less than N elements long.
sourcepub fn write_to_slice_unaligned(self, slice: &mut [i32])
pub fn write_to_slice_unaligned(self, slice: &mut [i32])
Writes the elements of self
to the first N elements in slice
.
Panics
Panics if slice
is less than N elements long.
sourcepub fn abs(self) -> IVec2
pub fn abs(self) -> IVec2
Returns a vector containing the absolute value of each element of self
.
Trait Implementations
sourceimpl AddAssign<IVec2> for IVec2
impl AddAssign<IVec2> for IVec2
sourcefn add_assign(&mut self, other: IVec2)
fn add_assign(&mut self, other: IVec2)
Performs the +=
operation. Read more
sourceimpl DivAssign<IVec2> for IVec2
impl DivAssign<IVec2> for IVec2
sourcefn div_assign(&mut self, other: IVec2)
fn div_assign(&mut self, other: IVec2)
Performs the /=
operation. Read more
sourceimpl DivAssign<i32> for IVec2
impl DivAssign<i32> for IVec2
sourcefn div_assign(&mut self, other: i32)
fn div_assign(&mut self, other: i32)
Performs the /=
operation. Read more
sourceimpl MulAssign<IVec2> for IVec2
impl MulAssign<IVec2> for IVec2
sourcefn mul_assign(&mut self, other: IVec2)
fn mul_assign(&mut self, other: IVec2)
Performs the *=
operation. Read more
sourceimpl MulAssign<i32> for IVec2
impl MulAssign<i32> for IVec2
sourcefn mul_assign(&mut self, other: i32)
fn mul_assign(&mut self, other: i32)
Performs the *=
operation. Read more
sourceimpl PartialOrd<IVec2> for IVec2
impl PartialOrd<IVec2> for IVec2
sourcefn partial_cmp(&self, other: &IVec2) -> Option<Ordering>
fn partial_cmp(&self, other: &IVec2) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl SubAssign<IVec2> for IVec2
impl SubAssign<IVec2> for IVec2
sourcefn sub_assign(&mut self, other: IVec2)
fn sub_assign(&mut self, other: IVec2)
Performs the -=
operation. Read more
sourceimpl Vec2Swizzles for IVec2
impl Vec2Swizzles for IVec2
type Vec3 = IVec3
type Vec4 = IVec4
fn xxxx(self) -> IVec4
fn xxxy(self) -> IVec4
fn xxyx(self) -> IVec4
fn xxyy(self) -> IVec4
fn xyxx(self) -> IVec4
fn xyxy(self) -> IVec4
fn xyyx(self) -> IVec4
fn xyyy(self) -> IVec4
fn yxxx(self) -> IVec4
fn yxxy(self) -> IVec4
fn yxyx(self) -> IVec4
fn yxyy(self) -> IVec4
fn yyxx(self) -> IVec4
fn yyxy(self) -> IVec4
fn yyyx(self) -> IVec4
fn yyyy(self) -> IVec4
fn xxx(self) -> IVec3
fn xxy(self) -> IVec3
fn xyx(self) -> IVec3
fn xyy(self) -> IVec3
fn yxx(self) -> IVec3
fn yxy(self) -> IVec3
fn yyx(self) -> IVec3
fn yyy(self) -> IVec3
fn xx(self) -> IVec2
fn yx(self) -> IVec2
fn yy(self) -> IVec2
fn xy(self) -> Self
impl Copy for IVec2
impl Eq for IVec2
Auto Trait Implementations
impl RefUnwindSafe for IVec2
impl Send for IVec2
impl Sync for IVec2
impl Unpin for IVec2
impl UnwindSafe for IVec2
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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