Struct kolor::Vec3[][src]

#[repr(transparent)]
pub struct Vec3(_);
Expand description

A 3-dimensional vector without SIMD support.

Implementations

impl Vec3[src]

pub const ZERO: Vec3[src]

All zeroes.

pub const ONE: Vec3[src]

All ones.

pub const X: Vec3[src]

[1, 0, 0]: a unit-length vector pointing along the positive X axis.

pub const Y: Vec3[src]

[0, 1, 0]: a unit-length vector pointing along the positive Y axis.

pub const Z: Vec3[src]

[0, 0, 1]: a unit-length vector pointing along the positive Z axis.

pub fn new(x: f32, y: f32, z: f32) -> Vec3[src]

Creates a new 3D vector.

pub const fn unit_x() -> Vec3[src]

👎 Deprecated:

Use Vec3::X instead

Creates a vector with values [x: 1.0, y: 0.0, z: 0.0].

pub const fn unit_y() -> Vec3[src]

👎 Deprecated:

Use Vec3::Y instead

Creates a vector with values [x: 0.0, y: 1.0, z: 0.0].

pub const fn unit_z() -> Vec3[src]

👎 Deprecated:

Use Vec3::Z instead

Creates a vector with values [x: 0.0, y: 0.0, z: 1.0].

pub fn extend(self, w: f32) -> Vec4[src]

Creates a 4D vector 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 cross(self, other: Vec3) -> Vec3[src]

Computes the cross product of self and other.

pub const fn zero() -> Vec3[src]

👎 Deprecated:

use ZERO constant instead

Creates a vector with all elements set to 0.0.

pub const fn one() -> Vec3[src]

👎 Deprecated:

use ONE constant instead

Creates a vector with all elements set to 1.0.

pub fn splat(v: f32) -> Vec3[src]

Creates a vector with all elements set to v.

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 dot(self, other: Vec3) -> f32[src]

Computes the dot product of self and other.

pub fn min(self, other: Vec3) -> Vec3[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: Vec3) -> Vec3[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: Vec3, max: Vec3) -> Vec3[src]

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.

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]

Returns the horizontal maximum of self.

In other words this computes max(x, y, ..).

pub fn cmpeq(self, other: Vec3) -> 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: Vec3) -> 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: Vec3) -> 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: Vec3) -> 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: Vec3) -> 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: Vec3) -> 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]) -> Vec3[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]

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) -> Vec3[src]

Returns a vector containing the absolute value of each element of self.

pub fn signum(self) -> Vec3[src]

Returns a vector with elements representing the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN

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(self) -> bool[src]

Returns true if any elements are NaN.

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(self) -> f32[src]

Computes the length of self.

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]

Computes 1.0 / 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) -> Vec3[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<Vec3>[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) -> Vec3[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]

Returns whether self is length 1.0 or not.

Uses a precision threshold of 1e-6.

pub fn round(self) -> Vec3[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) -> Vec3[src]

Returns a vector containing the largest integer less than or equal to a number for each element of self.

pub fn ceil(self) -> Vec3[src]

Returns a vector containing the smallest integer greater than or equal to a number for each element of self.

pub fn exp(self) -> Vec3[src]

Returns a vector containing e^self (the exponential function) for each element of self.

pub fn powf(self, n: f32) -> Vec3[src]

Returns a vector containing each element of self raised to the power of n.

pub fn recip(self) -> Vec3[src]

Returns a vector containing the reciprocal 1.0/n of each element of self.

pub fn lerp(self, other: Vec3, s: f32) -> Vec3[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: Vec3, 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) -> Vec3[src]

Returns a vector with a length no less than min and no more than max

pub fn clamp_length_max(self, max: f32) -> Vec3[src]

Returns a vector with a length no more than max

pub fn clamp_length_min(self, min: f32) -> Vec3[src]

Returns a vector with a length no less than min

pub fn angle_between(self, other: Vec3) -> 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) -> Vec3[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) -> Vec3[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) -> (Vec3, Vec3)[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.

pub fn as_f64(&self) -> DVec3[src]

Casts all elements of self to f64.

pub fn as_i32(&self) -> IVec3[src]

Casts all elements of self to i32.

pub fn as_u32(&self) -> UVec3[src]

Casts all elements of self to u32.

Trait Implementations

impl Add<Vec3> for Vec3[src]

type Output = Vec3

The resulting type after applying the + operator.

pub fn add(self, other: Vec3) -> Vec3[src]

Performs the + operation. Read more

impl AddAssign<Vec3> for Vec3[src]

pub fn add_assign(&mut self, other: Vec3)[src]

Performs the += operation. Read more

impl AsMut<[f32; 3]> for Vec3[src]

pub fn as_mut(&mut self) -> &mut [f32; 3][src]

Performs the conversion.

impl AsRef<[f32; 3]> for Vec3[src]

pub fn as_ref(&self) -> &[f32; 3][src]

Performs the conversion.

impl Clone for Vec3[src]

pub fn clone(&self) -> Vec3[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Vec3[src]

pub fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl Default for Vec3[src]

pub fn default() -> Vec3[src]

Returns the “default value” for a type. Read more

impl Deref for Vec3[src]

type Target = XYZ<f32>

The resulting type after dereferencing.

pub fn deref(&self) -> &<Vec3 as Deref>::Target[src]

Dereferences the value.

impl DerefMut for Vec3[src]

pub fn deref_mut(&mut self) -> &mut <Vec3 as Deref>::Target[src]

Mutably dereferences the value.

impl Display for Vec3[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl Div<Vec3> for Vec3[src]

type Output = Vec3

The resulting type after applying the / operator.

pub fn div(self, other: Vec3) -> Vec3[src]

Performs the / operation. Read more

impl Div<f32> for Vec3[src]

type Output = Vec3

The resulting type after applying the / operator.

pub fn div(self, other: f32) -> Vec3[src]

Performs the / operation. Read more

impl DivAssign<Vec3> for Vec3[src]

pub fn div_assign(&mut self, other: Vec3)[src]

Performs the /= operation. Read more

impl DivAssign<f32> for Vec3[src]

pub fn div_assign(&mut self, other: f32)[src]

Performs the /= operation. Read more

impl From<[f32; 3]> for Vec3[src]

pub fn from(a: [f32; 3]) -> Vec3[src]

Performs the conversion.

impl From<(Vec2, f32)> for Vec3[src]

pub fn from((Vec2, f32)) -> Vec3[src]

Performs the conversion.

impl From<(f32, f32, f32)> for Vec3[src]

pub fn from(t: (f32, f32, f32)) -> Vec3[src]

Performs the conversion.

impl From<Vec3> for XYZ<f32>[src]

pub fn from(t: Vec3) -> XYZ<f32>[src]

Performs the conversion.

impl From<Vec3A> for Vec3[src]

pub fn from(v: Vec3A) -> Vec3[src]

Performs the conversion.

impl From<Vec4> for Vec3[src]

pub fn from(v: Vec4) -> Vec3[src]

Creates a 3D vector from the x, y and z elements of self, discarding w.

impl From<XYZ<f32>> for Vec3[src]

pub fn from(t: XYZ<f32>) -> Vec3[src]

Performs the conversion.

impl Index<usize> for Vec3[src]

type Output = f32

The returned type after indexing.

pub fn index(&self, index: usize) -> &<Vec3 as Index<usize>>::Output[src]

Performs the indexing (container[index]) operation. Read more

impl IndexMut<usize> for Vec3[src]

pub fn index_mut(&mut self, index: usize) -> &mut <Vec3 as Index<usize>>::Output[src]

Performs the mutable indexing (container[index]) operation. Read more

impl Mul<Vec3> for Vec3[src]

type Output = Vec3

The resulting type after applying the * operator.

pub fn mul(self, other: Vec3) -> Vec3[src]

Performs the * operation. Read more

impl Mul<Vec3> for Mat3[src]

type Output = Vec3

The resulting type after applying the * operator.

pub fn mul(self, other: Vec3) -> Vec3[src]

Performs the * operation. Read more

impl Mul<f32> for Vec3[src]

type Output = Vec3

The resulting type after applying the * operator.

pub fn mul(self, other: f32) -> Vec3[src]

Performs the * operation. Read more

impl MulAssign<Vec3> for Vec3[src]

pub fn mul_assign(&mut self, other: Vec3)[src]

Performs the *= operation. Read more

impl MulAssign<f32> for Vec3[src]

pub fn mul_assign(&mut self, other: f32)[src]

Performs the *= operation. Read more

impl Neg for Vec3[src]

type Output = Vec3

The resulting type after applying the - operator.

pub fn neg(self) -> Vec3[src]

Performs the unary - operation. Read more

impl PartialEq<Vec3> for Vec3[src]

pub fn eq(&self, other: &Vec3) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialOrd<Vec3> for Vec3[src]

pub fn partial_cmp(&self, other: &Vec3) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<'a> Product<&'a Vec3> for Vec3[src]

pub fn product<I>(iter: I) -> Vec3 where
    I: Iterator<Item = &'a Vec3>, 
[src]

Method which takes an iterator and generates Self from the elements by multiplying the items. Read more

impl Sub<Vec3> for Vec3[src]

type Output = Vec3

The resulting type after applying the - operator.

pub fn sub(self, other: Vec3) -> Vec3[src]

Performs the - operation. Read more

impl SubAssign<Vec3> for Vec3[src]

pub fn sub_assign(&mut self, other: Vec3)[src]

Performs the -= operation. Read more

impl<'a> Sum<&'a Vec3> for Vec3[src]

pub fn sum<I>(iter: I) -> Vec3 where
    I: Iterator<Item = &'a Vec3>, 
[src]

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

impl Vec3Swizzles for Vec3[src]

type Vec2 = Vec2

type Vec4 = Vec4

pub fn xxxx(self) -> Vec4[src]

pub fn xxxy(self) -> Vec4[src]

pub fn xxxz(self) -> Vec4[src]

pub fn xxyx(self) -> Vec4[src]

pub fn xxyy(self) -> Vec4[src]

pub fn xxyz(self) -> Vec4[src]

pub fn xxzx(self) -> Vec4[src]

pub fn xxzy(self) -> Vec4[src]

pub fn xxzz(self) -> Vec4[src]

pub fn xyxx(self) -> Vec4[src]

pub fn xyxy(self) -> Vec4[src]

pub fn xyxz(self) -> Vec4[src]

pub fn xyyx(self) -> Vec4[src]

pub fn xyyy(self) -> Vec4[src]

pub fn xyyz(self) -> Vec4[src]

pub fn xyzx(self) -> Vec4[src]

pub fn xyzy(self) -> Vec4[src]

pub fn xyzz(self) -> Vec4[src]

pub fn xzxx(self) -> Vec4[src]

pub fn xzxy(self) -> Vec4[src]

pub fn xzxz(self) -> Vec4[src]

pub fn xzyx(self) -> Vec4[src]

pub fn xzyy(self) -> Vec4[src]

pub fn xzyz(self) -> Vec4[src]

pub fn xzzx(self) -> Vec4[src]

pub fn xzzy(self) -> Vec4[src]

pub fn xzzz(self) -> Vec4[src]

pub fn yxxx(self) -> Vec4[src]

pub fn yxxy(self) -> Vec4[src]

pub fn yxxz(self) -> Vec4[src]

pub fn yxyx(self) -> Vec4[src]

pub fn yxyy(self) -> Vec4[src]

pub fn yxyz(self) -> Vec4[src]

pub fn yxzx(self) -> Vec4[src]

pub fn yxzy(self) -> Vec4[src]

pub fn yxzz(self) -> Vec4[src]

pub fn yyxx(self) -> Vec4[src]

pub fn yyxy(self) -> Vec4[src]

pub fn yyxz(self) -> Vec4[src]

pub fn yyyx(self) -> Vec4[src]

pub fn yyyy(self) -> Vec4[src]

pub fn yyyz(self) -> Vec4[src]

pub fn yyzx(self) -> Vec4[src]

pub fn yyzy(self) -> Vec4[src]

pub fn yyzz(self) -> Vec4[src]

pub fn yzxx(self) -> Vec4[src]

pub fn yzxy(self) -> Vec4[src]

pub fn yzxz(self) -> Vec4[src]

pub fn yzyx(self) -> Vec4[src]

pub fn yzyy(self) -> Vec4[src]

pub fn yzyz(self) -> Vec4[src]

pub fn yzzx(self) -> Vec4[src]

pub fn yzzy(self) -> Vec4[src]

pub fn yzzz(self) -> Vec4[src]

pub fn zxxx(self) -> Vec4[src]

pub fn zxxy(self) -> Vec4[src]

pub fn zxxz(self) -> Vec4[src]

pub fn zxyx(self) -> Vec4[src]

pub fn zxyy(self) -> Vec4[src]

pub fn zxyz(self) -> Vec4[src]

pub fn zxzx(self) -> Vec4[src]

pub fn zxzy(self) -> Vec4[src]

pub fn zxzz(self) -> Vec4[src]

pub fn zyxx(self) -> Vec4[src]

pub fn zyxy(self) -> Vec4[src]

pub fn zyxz(self) -> Vec4[src]

pub fn zyyx(self) -> Vec4[src]

pub fn zyyy(self) -> Vec4[src]

pub fn zyyz(self) -> Vec4[src]

pub fn zyzx(self) -> Vec4[src]

pub fn zyzy(self) -> Vec4[src]

pub fn zyzz(self) -> Vec4[src]

pub fn zzxx(self) -> Vec4[src]

pub fn zzxy(self) -> Vec4[src]

pub fn zzxz(self) -> Vec4[src]

pub fn zzyx(self) -> Vec4[src]

pub fn zzyy(self) -> Vec4[src]

pub fn zzyz(self) -> Vec4[src]

pub fn zzzx(self) -> Vec4[src]

pub fn zzzy(self) -> Vec4[src]

pub fn zzzz(self) -> Vec4[src]

pub fn xxx(self) -> Vec3[src]

pub fn xxy(self) -> Vec3[src]

pub fn xxz(self) -> Vec3[src]

pub fn xyx(self) -> Vec3[src]

pub fn xyy(self) -> Vec3[src]

pub fn xzx(self) -> Vec3[src]

pub fn xzy(self) -> Vec3[src]

pub fn xzz(self) -> Vec3[src]

pub fn yxx(self) -> Vec3[src]

pub fn yxy(self) -> Vec3[src]

pub fn yxz(self) -> Vec3[src]

pub fn yyx(self) -> Vec3[src]

pub fn yyy(self) -> Vec3[src]

pub fn yyz(self) -> Vec3[src]

pub fn yzx(self) -> Vec3[src]

pub fn yzy(self) -> Vec3[src]

pub fn yzz(self) -> Vec3[src]

pub fn zxx(self) -> Vec3[src]

pub fn zxy(self) -> Vec3[src]

pub fn zxz(self) -> Vec3[src]

pub fn zyx(self) -> Vec3[src]

pub fn zyy(self) -> Vec3[src]

pub fn zyz(self) -> Vec3[src]

pub fn zzx(self) -> Vec3[src]

pub fn zzy(self) -> Vec3[src]

pub fn zzz(self) -> Vec3[src]

pub fn xx(self) -> Vec2[src]

pub fn xy(self) -> Vec2[src]

pub fn xz(self) -> Vec2[src]

pub fn yx(self) -> Vec2[src]

pub fn yy(self) -> Vec2[src]

pub fn yz(self) -> Vec2[src]

pub fn zx(self) -> Vec2[src]

pub fn zy(self) -> Vec2[src]

pub 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> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

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]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.