[−][src]Struct glam::Vec3
A 3-dimensional vector without SIMD support.
Fields
x: f32y: f32z: f32Implementations
impl Vec3[src]
pub fn new(x: f32, y: f32, z: f32) -> Self[src]
Creates a new Vec3.
pub const fn zero() -> Self[src]
Creates a Vec3 with all elements set to 0.0.
pub const fn one() -> Self[src]
Creates a Vec3 with all elements set to 1.0.
pub const fn unit_x() -> Self[src]
Creates a Vec3 with values [x: 1.0, y: 0.0, z: 0.0].
pub const fn unit_y() -> Self[src]
Creates a Vec3 with values [x: 0.0, y: 1.0, z: 0.0].
pub const fn unit_z() -> Self[src]
Creates a Vec3 with values [x: 0.0, y: 0.0, z: 1.0].
pub fn splat(v: f32) -> Self[src]
Creates a Vec3 with all elements set to v.
pub fn extend(self, w: f32) -> Vec4[src]
Creates a Vec4 from self and the given w value.
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 x(self) -> f32[src]
please use .x instead
pub fn y(self) -> f32[src]
please use .y instead
pub fn z(self) -> f32[src]
please use .z instead
pub fn x_mut(&mut self) -> &mut f32[src]
please use .x instead
pub fn y_mut(&mut self) -> &mut f32[src]
please use .y instead
pub fn z_mut(&mut self) -> &mut f32[src]
please use .z instead
pub fn set_x(&mut self, x: f32)[src]
please use .x instead
pub fn set_y(&mut self, y: f32)[src]
please use .y instead
pub fn set_z(&mut self, z: f32)[src]
please use .z instead
pub fn dot(self, other: Self) -> f32[src]
Computes the dot product of self and other.
pub fn cross(self, other: Self) -> Self[src]
Computes the cross product of self and other.
pub fn length(self) -> f32[src]
Computes the length of self.
pub fn length_squared(self) -> f32[src]
Computes the squared length of self.
This is generally faster than Vec3::length() as it avoids a square
root operation.
pub fn length_recip(self) -> f32[src]
Computes 1.0 / Vec3::length().
For valid results, self must not be of length zero.
pub fn distance(self, other: Vec3) -> f32[src]
Computes the Euclidean distance between two points in space.
pub fn distance_squared(self, other: Vec3) -> f32[src]
Compute the squared Euclidean distance between two points in space.
pub fn normalize(self) -> Self[src]
Returns self normalized to length 1.0.
For valid results, self must not be of length zero.
pub fn min(self, other: Self) -> Self[src]
Returns the vertical minimum of self and other.
In other words, this computes
[x: min(x1, x2), y: min(y1, y2), z: min(z1, z2)],
taking the minimum of each element individually.
pub fn max(self, other: Self) -> Self[src]
Returns the vertical maximum of self and other.
In other words, this computes
[x: max(x1, x2), y: max(y1, y2), z: max(z1, z2)],
taking the maximum of each element individually.
pub fn min_element(self) -> f32[src]
Returns the horizontal minimum of self's elements.
In other words, this computes min(x, y, z).
pub fn max_element(self) -> f32[src]
Returns the horizontal maximum of self's elements.
In other words, this computes max(x, y, z).
pub fn cmpeq(self, other: Self) -> Vec3Mask[src]
Performs a vertical == comparison between self and other,
returning a Vec3Mask of the results.
In other words, this computes [x1 == x2, y1 == y2, z1 == z2].
pub fn cmpne(self, other: Self) -> Vec3Mask[src]
Performs a vertical != comparison between self and other,
returning a Vec3Mask of the results.
In other words, this computes [x1 != x2, y1 != y2, z1 != z2].
pub fn cmpge(self, other: Self) -> Vec3Mask[src]
Performs a vertical >= comparison between self and other,
returning a Vec3Mask of the results.
In other words, this computes [x1 >= x2, y1 >= y2, z1 >= z2].
pub fn cmpgt(self, other: Self) -> Vec3Mask[src]
Performs a vertical > comparison between self and other,
returning a Vec3Mask of the results.
In other words, this computes [x1 > x2, y1 > y2, z1 > z2].
pub fn cmple(self, other: Self) -> Vec3Mask[src]
Performs a vertical <= comparison between self and other,
returning a Vec3Mask of the results.
In other words, this computes [x1 <= x2, y1 <= y2, z1 <= z2].
pub fn cmplt(self, other: Self) -> Vec3Mask[src]
Performs a vertical < comparison between self and other,
returning a Vec3Mask of the results.
In other words, this computes [x1 < x2, y1 < y2, z1 < z2].
pub fn from_slice_unaligned(slice: &[f32]) -> Self[src]
Creates a Vec3 from the first three values in slice.
Panics
Panics if slice is less than three elements long.
pub fn write_to_slice_unaligned(self, slice: &mut [f32])[src]
Writes the elements of self to the first three elements in slice.
Panics
Panics if slice is less than three elements long.
pub fn abs(self) -> Self[src]
Returns a Vec3 containing the absolute value of each element of self.
pub fn round(self) -> Self[src]
Returns a Vec3 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]
Returns a Vec3 containing the largest integer less than or equal to a number for each
element of self.
pub fn ceil(self) -> Self[src]
Returns a Vec3 containing the smallest integer greater than or equal to a number for each
element of self.
pub fn is_nan(self) -> Vec3Mask[src]
Performs is_nan() on each element of self, returning a Vec3Mask of the results.
In other words, this computes [x.is_nan(), y.is_nan(), z.is_nan()].
pub fn signum(self) -> Self[src]
Returns a Vec3 with elements representing the sign of self.
1.0if the number is positive,+0.0orINFINITY-1.0if the number is negative,-0.0orNEG_INFINITYNANif the number isNAN
pub fn recip(self) -> Self[src]
Returns a Vec3 containing the reciprocal 1.0/n of each element of self.
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 is_normalized(self) -> bool[src]
Returns whether self of length 1.0 or not.
Uses a precision threshold of 1e-6.
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 Vec3's 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 on floating point comparisons see https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
pub fn angle_between(self, other: Self) -> f32[src]
Returns the angle between two vectors, in radians.
The vectors do not need to be unit length, but this function does
perform a sqrt.
Trait Implementations
impl Add<Vec3> for Vec3[src]
type Output = Self
The resulting type after applying the + operator.
fn add(self, other: Self) -> Self[src]
impl AddAssign<Vec3> for Vec3[src]
fn add_assign(&mut self, other: Self)[src]
impl AsMut<[f32; 3]> for Vec3[src]
impl AsRef<[f32; 3]> for Vec3[src]
impl Clone for Vec3[src]
impl Copy for Vec3[src]
impl Debug for Vec3[src]
impl Default for Vec3[src]
impl Display for Vec3[src]
impl Div<Vec3> for Vec3[src]
type Output = Self
The resulting type after applying the / operator.
fn div(self, other: Self) -> Self[src]
impl Div<Vec3> for f32[src]
type Output = Vec3
The resulting type after applying the / operator.
fn div(self, other: Vec3) -> Vec3[src]
impl Div<f32> for Vec3[src]
type Output = Self
The resulting type after applying the / operator.
fn div(self, other: f32) -> Self[src]
impl DivAssign<Vec3> for Vec3[src]
fn div_assign(&mut self, other: Self)[src]
impl DivAssign<f32> for Vec3[src]
fn div_assign(&mut self, other: f32)[src]
impl From<[f32; 3]> for Vec3[src]
impl From<(f32, f32, f32)> for Vec3[src]
impl From<Vec3> for (f32, f32, f32)[src]
impl From<Vec3> for [f32; 3][src]
impl From<Vec3> for Vec2[src]
impl From<Vec3> for Vec3A[src]
impl From<Vec3A> for Vec3[src]
impl From<Vec4> for Vec3[src]
impl Index<usize> for Vec3[src]
type Output = f32
The returned type after indexing.
fn index(&self, index: usize) -> &Self::Output[src]
impl IndexMut<usize> for Vec3[src]
impl Mul<Vec3> for Mat3[src]
type Output = Vec3
The resulting type after applying the * operator.
fn mul(self, other: Vec3) -> Vec3[src]
impl Mul<Vec3> for Quat[src]
type Output = Vec3
The resulting type after applying the * operator.
fn mul(self, other: Vec3) -> Self::Output[src]
impl Mul<Vec3> for Vec3[src]
type Output = Self
The resulting type after applying the * operator.
fn mul(self, other: Self) -> Self[src]
impl Mul<Vec3> for f32[src]
type Output = Vec3
The resulting type after applying the * operator.
fn mul(self, other: Vec3) -> Vec3[src]
impl Mul<f32> for Vec3[src]
type Output = Self
The resulting type after applying the * operator.
fn mul(self, other: f32) -> Self[src]
impl MulAssign<Vec3> for Vec3[src]
fn mul_assign(&mut self, other: Self)[src]
impl MulAssign<f32> for Vec3[src]
fn mul_assign(&mut self, other: f32)[src]
impl Neg for Vec3[src]
impl PartialEq<Vec3> for Vec3[src]
impl PartialOrd<Vec3> for Vec3[src]
fn partial_cmp(&self, other: &Vec3) -> Option<Ordering>[src]
fn lt(&self, other: &Vec3) -> bool[src]
fn le(&self, other: &Vec3) -> bool[src]
fn gt(&self, other: &Vec3) -> bool[src]
fn ge(&self, other: &Vec3) -> bool[src]
impl<'a> Product<&'a Vec3> for Vec3[src]
impl StructuralPartialEq for Vec3[src]
impl Sub<Vec3> for Vec3[src]
type Output = Self
The resulting type after applying the - operator.
fn sub(self, other: Self) -> Self[src]
impl SubAssign<Vec3> for Vec3[src]
fn sub_assign(&mut self, other: Self)[src]
impl<'a> Sum<&'a Vec3> for Vec3[src]
impl Vec3Swizzles for Vec3[src]
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) -> Vec3[src]
fn xxy(self) -> Vec3[src]
fn xxz(self) -> Vec3[src]
fn xyx(self) -> Vec3[src]
fn xyy(self) -> Vec3[src]
fn xzx(self) -> Vec3[src]
fn xzy(self) -> Vec3[src]
fn xzz(self) -> Vec3[src]
fn yxx(self) -> Vec3[src]
fn yxy(self) -> Vec3[src]
fn yxz(self) -> Vec3[src]
fn yyx(self) -> Vec3[src]
fn yyy(self) -> Vec3[src]
fn yyz(self) -> Vec3[src]
fn yzx(self) -> Vec3[src]
fn yzy(self) -> Vec3[src]
fn yzz(self) -> Vec3[src]
fn zxx(self) -> Vec3[src]
fn zxy(self) -> Vec3[src]
fn zxz(self) -> Vec3[src]
fn zyx(self) -> Vec3[src]
fn zyy(self) -> Vec3[src]
fn zyz(self) -> Vec3[src]
fn zzx(self) -> Vec3[src]
fn zzy(self) -> Vec3[src]
fn zzz(self) -> Vec3[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]
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> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,