#[repr(C)]pub struct IVec4 {
pub x: i32,
pub y: i32,
pub z: i32,
pub w: i32,
}
Expand description
A 4-dimensional vector.
Fields§
§x: i32
§y: i32
§z: i32
§w: i32
Implementations§
Source§impl IVec4
impl IVec4
Sourcepub fn select(mask: BVec4, if_true: IVec4, if_false: IVec4) -> IVec4
pub fn select(mask: BVec4, if_true: IVec4, if_false: IVec4) -> IVec4
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 const fn from_array(a: [i32; 4]) -> IVec4
pub const fn from_array(a: [i32; 4]) -> IVec4
Creates a new vector from an array.
Sourcepub const fn from_slice(slice: &[i32]) -> IVec4
pub const fn from_slice(slice: &[i32]) -> IVec4
Creates a vector from the first 4 values in slice
.
§Panics
Panics if slice
is less than 4 elements long.
Sourcepub fn write_to_slice(self, slice: &mut [i32])
pub fn write_to_slice(self, slice: &mut [i32])
Writes the elements of self
to the first 4 elements in slice
.
§Panics
Panics if slice
is less than 4 elements long.
Sourcepub fn truncate(self) -> IVec3
pub fn truncate(self) -> IVec3
Creates a 2D vector from the x
, y
and z
elements of self
, discarding w
.
Truncation to IVec3
may also be performed by using self.xyz()
or IVec3::from()
.
Sourcepub fn dot_into_vec(self, rhs: IVec4) -> IVec4
pub fn dot_into_vec(self, rhs: IVec4) -> IVec4
Returns a vector where every component is the dot product of self
and rhs
.
Sourcepub fn min(self, rhs: IVec4) -> IVec4
pub fn min(self, rhs: IVec4) -> IVec4
Returns a vector containing the minimum values for each element of self
and rhs
.
In other words this computes [self.x.min(rhs.x), self.y.min(rhs.y), ..]
.
Sourcepub fn max(self, rhs: IVec4) -> IVec4
pub fn max(self, rhs: IVec4) -> IVec4
Returns a vector containing the maximum values for each element of self
and rhs
.
In other words this computes [self.x.max(rhs.x), self.y.max(rhs.y), ..]
.
Sourcepub fn clamp(self, min: IVec4, max: IVec4) -> IVec4
pub fn clamp(self, min: IVec4, max: IVec4) -> IVec4
Component-wise clamping of values, similar to i32::clamp
.
Each element in min
must be less-or-equal to the corresponding element in max
.
§Panics
Will panic if min
is greater than max
when glam_assert
is enabled.
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, rhs: IVec4) -> BVec4
pub fn cmpeq(self, rhs: IVec4) -> BVec4
Returns a vector mask containing the result of a ==
comparison for each element of
self
and rhs
.
In other words, this computes [self.x == rhs.x, self.y == rhs.y, ..]
for all
elements.
Sourcepub fn cmpne(self, rhs: IVec4) -> BVec4
pub fn cmpne(self, rhs: IVec4) -> BVec4
Returns a vector mask containing the result of a !=
comparison for each element of
self
and rhs
.
In other words this computes [self.x != rhs.x, self.y != rhs.y, ..]
for all
elements.
Sourcepub fn cmpge(self, rhs: IVec4) -> BVec4
pub fn cmpge(self, rhs: IVec4) -> BVec4
Returns a vector mask containing the result of a >=
comparison for each element of
self
and rhs
.
In other words this computes [self.x >= rhs.x, self.y >= rhs.y, ..]
for all
elements.
Sourcepub fn cmpgt(self, rhs: IVec4) -> BVec4
pub fn cmpgt(self, rhs: IVec4) -> BVec4
Returns a vector mask containing the result of a >
comparison for each element of
self
and rhs
.
In other words this computes [self.x > rhs.x, self.y > rhs.y, ..]
for all
elements.
Sourcepub fn cmple(self, rhs: IVec4) -> BVec4
pub fn cmple(self, rhs: IVec4) -> BVec4
Returns a vector mask containing the result of a <=
comparison for each element of
self
and rhs
.
In other words this computes [self.x <= rhs.x, self.y <= rhs.y, ..]
for all
elements.
Sourcepub fn cmplt(self, rhs: IVec4) -> BVec4
pub fn cmplt(self, rhs: IVec4) -> BVec4
Returns a vector mask containing the result of a <
comparison for each element of
self
and rhs
.
In other words this computes [self.x < rhs.x, self.y < rhs.y, ..]
for all
elements.
Sourcepub fn abs(self) -> IVec4
pub fn abs(self) -> IVec4
Returns a vector containing the absolute value of each element of self
.
Sourcepub fn signum(self) -> IVec4
pub fn signum(self) -> IVec4
Returns a vector with elements representing the sign of self
.
0
if the number is zero1
if the number is positive-1
if the number is negative
Sourcepub fn copysign(self, rhs: IVec4) -> IVec4
pub fn copysign(self, rhs: IVec4) -> IVec4
Returns a vector with signs of rhs
and the magnitudes of self
.
Sourcepub fn is_negative_bitmask(self) -> u32
pub fn is_negative_bitmask(self) -> u32
Returns a bitmask with the lowest 4 bits set to the sign bits from the elements of self
.
A negative element results in a 1
bit and a positive element in a 0
bit. Element x
goes
into the first lowest bit, element y
into the second, etc.
Trait Implementations§
Source§impl AddAssign<i32> for IVec4
impl AddAssign<i32> for IVec4
Source§fn add_assign(&mut self, rhs: i32)
fn add_assign(&mut self, rhs: i32)
+=
operation. Read moreSource§impl AddAssign for IVec4
impl AddAssign for IVec4
Source§fn add_assign(&mut self, rhs: IVec4)
fn add_assign(&mut self, rhs: IVec4)
+=
operation. Read moreSource§impl DivAssign<i32> for IVec4
impl DivAssign<i32> for IVec4
Source§fn div_assign(&mut self, rhs: i32)
fn div_assign(&mut self, rhs: i32)
/=
operation. Read moreSource§impl DivAssign for IVec4
impl DivAssign for IVec4
Source§fn div_assign(&mut self, rhs: IVec4)
fn div_assign(&mut self, rhs: IVec4)
/=
operation. Read moreSource§impl MulAssign<i32> for IVec4
impl MulAssign<i32> for IVec4
Source§fn mul_assign(&mut self, rhs: i32)
fn mul_assign(&mut self, rhs: i32)
*=
operation. Read moreSource§impl MulAssign for IVec4
impl MulAssign for IVec4
Source§fn mul_assign(&mut self, rhs: IVec4)
fn mul_assign(&mut self, rhs: IVec4)
*=
operation. Read moreSource§impl RemAssign<i32> for IVec4
impl RemAssign<i32> for IVec4
Source§fn rem_assign(&mut self, rhs: i32)
fn rem_assign(&mut self, rhs: i32)
%=
operation. Read moreSource§impl RemAssign for IVec4
impl RemAssign for IVec4
Source§fn rem_assign(&mut self, rhs: IVec4)
fn rem_assign(&mut self, rhs: IVec4)
%=
operation. Read moreSource§impl SubAssign<i32> for IVec4
impl SubAssign<i32> for IVec4
Source§fn sub_assign(&mut self, rhs: i32)
fn sub_assign(&mut self, rhs: i32)
-=
operation. Read moreSource§impl SubAssign for IVec4
impl SubAssign for IVec4
Source§fn sub_assign(&mut self, rhs: IVec4)
fn sub_assign(&mut self, rhs: IVec4)
-=
operation. Read more