Struct glam::f32::Vec3 [−][src]
#[repr(transparent)]pub struct Vec3(_);
Expand description
A 3-dimensional vector without SIMD support.
Implementations
impl Vec3
[src]
impl Vec3
[src]pub fn truncate(self) -> Vec2
[src]
pub fn truncate(self) -> Vec2
[src]Creates a Vec2
from the x
and y
elements of self
, discarding z
.
Truncation may also be performed by using self.xy()
or Vec2::from()
.
pub fn select(mask: BVec3, if_true: Vec3, if_false: Vec3) -> Vec3
[src]
pub fn select(mask: BVec3, if_true: Vec3, if_false: Vec3) -> Vec3
[src]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
.
pub fn min(self, other: Self) -> Self
[src]
pub fn min(self, other: Self) -> Self
[src]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), ..]
.
pub fn max(self, other: Self) -> Self
[src]
pub fn max(self, other: Self) -> Self
[src]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), ..]
.
pub fn clamp(self, min: Self, max: Self) -> Self
[src]
pub fn clamp(self, min: Self, max: Self) -> Self
[src]Component-wise clamping of values, similar to 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.
pub fn min_element(self) -> f32
[src]
pub fn min_element(self) -> f32
[src]Returns the horizontal minimum of self
.
In other words this computes min(x, y, ..)
.
pub fn max_element(self) -> f32
[src]
pub fn max_element(self) -> f32
[src]Returns the horizontal maximum of self
.
In other words this computes max(x, y, ..)
.
pub fn cmpeq(self, other: Self) -> BVec3
[src]
pub fn cmpeq(self, other: Self) -> BVec3
[src]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.
pub fn cmpne(self, other: Self) -> BVec3
[src]
pub fn cmpne(self, other: Self) -> BVec3
[src]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.
pub fn cmpge(self, other: Self) -> BVec3
[src]
pub fn cmpge(self, other: Self) -> BVec3
[src]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.
pub fn cmpgt(self, other: Self) -> BVec3
[src]
pub fn cmpgt(self, other: Self) -> BVec3
[src]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.
pub fn cmple(self, other: Self) -> BVec3
[src]
pub fn cmple(self, other: Self) -> BVec3
[src]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.
pub fn cmplt(self, other: Self) -> BVec3
[src]
pub fn cmplt(self, other: Self) -> BVec3
[src]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.
pub fn from_slice_unaligned(slice: &[f32]) -> Self
[src]
Please use from_slice()
instead
pub fn from_slice(slice: &[f32]) -> Self
[src]
pub fn from_slice(slice: &[f32]) -> Self
[src]Creates a vector from the first N values in slice
.
Panics
Panics if slice
is less than N elements long.
pub fn write_to_slice_unaligned(self, slice: &mut [f32])
[src]
Please use write_to_slice()
instead
pub fn write_to_slice(self, slice: &mut [f32])
[src]
pub fn write_to_slice(self, slice: &mut [f32])
[src]Writes the elements of self
to the first N elements in slice
.
Panics
Panics if slice
is less than N elements long.
pub fn abs(self) -> Self
[src]
pub fn abs(self) -> Self
[src]Returns a vector containing the absolute value of each element of self
.
pub fn signum(self) -> Self
[src]
pub fn signum(self) -> Self
[src]Returns a vector with elements representing the sign of self
.
1.0
if the number is positive,+0.0
orINFINITY
-1.0
if the number is negative,-0.0
orNEG_INFINITY
NAN
if the number isNAN
pub fn is_finite(self) -> bool
[src]
pub fn is_finite(self) -> bool
[src]Returns true
if, and only if, all elements are finite. If any element is either
NaN
, positive or negative infinity, this will return false
.
pub fn is_nan_mask(self) -> BVec3
[src]
pub fn is_nan_mask(self) -> BVec3
[src]Performs is_nan
on each element of self, returning a vector mask of the results.
In other words, this computes [x.is_nan(), y.is_nan(), z.is_nan(), w.is_nan()]
.
pub fn length_squared(self) -> f32
[src]
pub fn length_squared(self) -> f32
[src]Computes the squared length of self
.
This is faster than length()
as it avoids a square root operation.
pub fn length_recip(self) -> f32
[src]
pub fn length_recip(self) -> f32
[src]Computes 1.0 / length()
.
For valid results, self
must not be of length zero.
pub fn distance(self, other: Self) -> f32
[src]
pub fn distance(self, other: Self) -> f32
[src]Computes the Euclidean distance between two points in space.
pub fn distance_squared(self, other: Self) -> f32
[src]
pub fn distance_squared(self, other: Self) -> f32
[src]Compute the squared euclidean distance between two points in space.
pub fn normalize(self) -> Self
[src]
pub fn normalize(self) -> Self
[src]Returns self
normalized to length 1.0.
For valid results, self
must not be of length zero, nor very close to zero.
See also Self::try_normalize
and Self::normalize_or_zero
.
pub fn try_normalize(self) -> Option<Self>
[src]
pub fn try_normalize(self) -> Option<Self>
[src]Returns self
normalized to length 1.0 if possible, else returns None
.
In particular, if the input is zero (or very close to zero), or non-finite,
the result of this operation will be None
.
See also Self::normalize_or_zero
.
pub fn normalize_or_zero(self) -> Self
[src]
pub fn normalize_or_zero(self) -> Self
[src]Returns self
normalized to length 1.0 if possible, else returns zero.
In particular, if the input is zero (or very close to zero), or non-finite, the result of this operation will be zero.
See also Self::try_normalize
.
pub fn is_normalized(self) -> bool
[src]
pub fn is_normalized(self) -> bool
[src]Returns whether self
is length 1.0
or not.
Uses a precision threshold of 1e-6
.
pub fn round(self) -> Self
[src]
pub fn round(self) -> Self
[src]Returns a vector containing the nearest integer to a number for each element of self
.
Round half-way cases away from 0.0.
pub fn floor(self) -> Self
[src]
pub fn floor(self) -> Self
[src]Returns a vector containing the largest integer less than or equal to a number for each
element of self
.
pub fn ceil(self) -> Self
[src]
pub fn ceil(self) -> Self
[src]Returns a vector containing the smallest integer greater than or equal to a number for
each element of self
.
pub fn exp(self) -> Self
[src]
pub fn exp(self) -> Self
[src]Returns a vector containing e^self
(the exponential function) for each element of
self
.
pub fn powf(self, n: f32) -> Self
[src]
pub fn powf(self, n: f32) -> Self
[src]Returns a vector containing each element of self
raised to the power of n
.
pub fn recip(self) -> Self
[src]
pub fn recip(self) -> Self
[src]Returns a vector containing the reciprocal 1.0/n
of each element of self
.
pub fn lerp(self, other: Self, s: f32) -> Self
[src]
pub fn lerp(self, other: Self, s: f32) -> Self
[src]Performs a linear interpolation between self
and other
based on the value s
.
When s
is 0.0
, the result will be equal to self
. When s
is 1.0
, the result
will be equal to other
.
pub fn abs_diff_eq(self, other: Self, max_abs_diff: f32) -> bool
[src]
pub fn abs_diff_eq(self, other: Self, max_abs_diff: f32) -> bool
[src]Returns true if the absolute difference of all elements between self
and other
is
less than or equal to max_abs_diff
.
This can be used to compare if two vectors contain similar elements. It works best when
comparing with a known value. The max_abs_diff
that should be used used depends on
the values being compared against.
For more see comparing floating point numbers.
pub fn clamp_length(self, min: f32, max: f32) -> Self
[src]
pub fn clamp_length(self, min: f32, max: f32) -> Self
[src]Returns a vector with a length no less than min
and no more than max
pub fn clamp_length_max(self, max: f32) -> Self
[src]
pub fn clamp_length_max(self, max: f32) -> Self
[src]Returns a vector with a length no more than max
pub fn clamp_length_min(self, min: f32) -> Self
[src]
pub fn clamp_length_min(self, min: f32) -> Self
[src]Returns a vector with a length no less than min
pub fn angle_between(self, other: Self) -> f32
[src]
pub fn angle_between(self, other: Self) -> f32
[src]Returns the angle (in radians) between two vectors.
The input vectors do not need to be unit length however they must be non-zero.
pub fn any_orthogonal_vector(&self) -> Self
[src]
pub fn any_orthogonal_vector(&self) -> Self
[src]Returns somes vector that is orthogonal to the given one.
The input vector must be finite and non-zero.
The output vector is not necessarily unit-length.
For that use Self::any_orthonormal_vector
instead.
pub fn any_orthonormal_vector(&self) -> Self
[src]
pub fn any_orthonormal_vector(&self) -> Self
[src]Returns any unit-length vector that is orthogonal to the given one. The input vector must be finite and non-zero.
pub fn any_orthonormal_pair(&self) -> (Self, Self)
[src]
pub fn any_orthonormal_pair(&self) -> (Self, Self)
[src]Given a unit-length vector return two other vectors that together form an orthonormal basis. That is, all three vectors are orthogonal to each other and are normalized.
Trait Implementations
impl AddAssign<Vec3> for Vec3
[src]
impl AddAssign<Vec3> for Vec3
[src]fn add_assign(&mut self, other: Self)
[src]
fn add_assign(&mut self, other: Self)
[src]Performs the +=
operation. Read more
impl DivAssign<Vec3> for Vec3
[src]
impl DivAssign<Vec3> for Vec3
[src]fn div_assign(&mut self, other: Vec3)
[src]
fn div_assign(&mut self, other: Vec3)
[src]Performs the /=
operation. Read more
impl DivAssign<f32> for Vec3
[src]
impl DivAssign<f32> for Vec3
[src]fn div_assign(&mut self, other: f32)
[src]
fn div_assign(&mut self, other: f32)
[src]Performs the /=
operation. Read more
impl MulAssign<Vec3> for Vec3
[src]
impl MulAssign<Vec3> for Vec3
[src]fn mul_assign(&mut self, other: Vec3)
[src]
fn mul_assign(&mut self, other: Vec3)
[src]Performs the *=
operation. Read more
impl MulAssign<f32> for Vec3
[src]
impl MulAssign<f32> for Vec3
[src]fn mul_assign(&mut self, other: f32)
[src]
fn mul_assign(&mut self, other: f32)
[src]Performs the *=
operation. Read more
impl SubAssign<Vec3> for Vec3
[src]
impl SubAssign<Vec3> for Vec3
[src]fn sub_assign(&mut self, other: Vec3)
[src]
fn sub_assign(&mut self, other: Vec3)
[src]Performs the -=
operation. Read more
impl Vec3Swizzles for Vec3
[src]
impl Vec3Swizzles for Vec3
[src]type Vec2 = Vec2
type Vec4 = Vec4
fn xxxx(self) -> Vec4
[src]
fn xxxy(self) -> Vec4
[src]
fn xxxz(self) -> Vec4
[src]
fn xxyx(self) -> Vec4
[src]
fn xxyy(self) -> Vec4
[src]
fn xxyz(self) -> Vec4
[src]
fn xxzx(self) -> Vec4
[src]
fn xxzy(self) -> Vec4
[src]
fn xxzz(self) -> Vec4
[src]
fn xyxx(self) -> Vec4
[src]
fn xyxy(self) -> Vec4
[src]
fn xyxz(self) -> Vec4
[src]
fn xyyx(self) -> Vec4
[src]
fn xyyy(self) -> Vec4
[src]
fn xyyz(self) -> Vec4
[src]
fn xyzx(self) -> Vec4
[src]
fn xyzy(self) -> Vec4
[src]
fn xyzz(self) -> Vec4
[src]
fn xzxx(self) -> Vec4
[src]
fn xzxy(self) -> Vec4
[src]
fn xzxz(self) -> Vec4
[src]
fn xzyx(self) -> Vec4
[src]
fn xzyy(self) -> Vec4
[src]
fn xzyz(self) -> Vec4
[src]
fn xzzx(self) -> Vec4
[src]
fn xzzy(self) -> Vec4
[src]
fn xzzz(self) -> Vec4
[src]
fn yxxx(self) -> Vec4
[src]
fn yxxy(self) -> Vec4
[src]
fn yxxz(self) -> Vec4
[src]
fn yxyx(self) -> Vec4
[src]
fn yxyy(self) -> Vec4
[src]
fn yxyz(self) -> Vec4
[src]
fn yxzx(self) -> Vec4
[src]
fn yxzy(self) -> Vec4
[src]
fn yxzz(self) -> Vec4
[src]
fn yyxx(self) -> Vec4
[src]
fn yyxy(self) -> Vec4
[src]
fn yyxz(self) -> Vec4
[src]
fn yyyx(self) -> Vec4
[src]
fn yyyy(self) -> Vec4
[src]
fn yyyz(self) -> Vec4
[src]
fn yyzx(self) -> Vec4
[src]
fn yyzy(self) -> Vec4
[src]
fn yyzz(self) -> Vec4
[src]
fn yzxx(self) -> Vec4
[src]
fn yzxy(self) -> Vec4
[src]
fn yzxz(self) -> Vec4
[src]
fn yzyx(self) -> Vec4
[src]
fn yzyy(self) -> Vec4
[src]
fn yzyz(self) -> Vec4
[src]
fn yzzx(self) -> Vec4
[src]
fn yzzy(self) -> Vec4
[src]
fn yzzz(self) -> Vec4
[src]
fn zxxx(self) -> Vec4
[src]
fn zxxy(self) -> Vec4
[src]
fn zxxz(self) -> Vec4
[src]
fn zxyx(self) -> Vec4
[src]
fn zxyy(self) -> Vec4
[src]
fn zxyz(self) -> Vec4
[src]
fn zxzx(self) -> Vec4
[src]
fn zxzy(self) -> Vec4
[src]
fn zxzz(self) -> Vec4
[src]
fn zyxx(self) -> Vec4
[src]
fn zyxy(self) -> Vec4
[src]
fn zyxz(self) -> Vec4
[src]
fn zyyx(self) -> Vec4
[src]
fn zyyy(self) -> Vec4
[src]
fn zyyz(self) -> Vec4
[src]
fn zyzx(self) -> Vec4
[src]
fn zyzy(self) -> Vec4
[src]
fn zyzz(self) -> Vec4
[src]
fn zzxx(self) -> Vec4
[src]
fn zzxy(self) -> Vec4
[src]
fn zzxz(self) -> Vec4
[src]
fn zzyx(self) -> Vec4
[src]
fn zzyy(self) -> Vec4
[src]
fn zzyz(self) -> Vec4
[src]
fn zzzx(self) -> Vec4
[src]
fn zzzy(self) -> Vec4
[src]
fn zzzz(self) -> Vec4
[src]
fn xxx(self) -> Self
[src]
fn xxy(self) -> Self
[src]
fn xxz(self) -> Self
[src]
fn xyx(self) -> Self
[src]
fn xyy(self) -> Self
[src]
fn xzx(self) -> Self
[src]
fn xzy(self) -> Self
[src]
fn xzz(self) -> Self
[src]
fn yxx(self) -> Self
[src]
fn yxy(self) -> Self
[src]
fn yxz(self) -> Self
[src]
fn yyx(self) -> Self
[src]
fn yyy(self) -> Self
[src]
fn yyz(self) -> Self
[src]
fn yzx(self) -> Self
[src]
fn yzy(self) -> Self
[src]
fn yzz(self) -> Self
[src]
fn zxx(self) -> Self
[src]
fn zxy(self) -> Self
[src]
fn zxz(self) -> Self
[src]
fn zyx(self) -> Self
[src]
fn zyy(self) -> Self
[src]
fn zyz(self) -> Self
[src]
fn zzx(self) -> Self
[src]
fn zzy(self) -> Self
[src]
fn zzz(self) -> Self
[src]
fn xx(self) -> Vec2
[src]
fn xy(self) -> Vec2
[src]
fn xz(self) -> Vec2
[src]
fn yx(self) -> Vec2
[src]
fn yy(self) -> Vec2
[src]
fn yz(self) -> Vec2
[src]
fn zx(self) -> Vec2
[src]
fn zy(self) -> Vec2
[src]
fn zz(self) -> Vec2
[src]
fn xyz(self) -> Self
[src]
impl Copy for Vec3
[src]
Auto Trait Implementations
impl RefUnwindSafe for Vec3
impl Send for Vec3
impl Sync for Vec3
impl Unpin for Vec3
impl UnwindSafe for Vec3
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more