Struct bevy::prelude::Vec4[][src]

#[repr(transparent)]pub struct Vec4(_);

A 4-dimensional vector.

This type uses 16 byte aligned SIMD vector type for storage on supported platforms.

Implementations

impl Vec4[src]

pub const ZERO: Vec4[src]

All zeroes.

pub const ONE: Vec4[src]

All ones.

pub const X: Vec4[src]

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

pub const Y: Vec4[src]

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

pub const Z: Vec4[src]

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

pub const W: Vec4[src]

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

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

Creates a new 4D vector.

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

👎 Deprecated:

Use Vec4::X instead

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

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

👎 Deprecated:

Use Vec4::Y instead

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

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

👎 Deprecated:

Use Vec4::Z instead

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

pub const fn unit_w() -> Vec4[src]

👎 Deprecated:

Use Vec4::W instead

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

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

Creates a Vec3 from the x, y and z elements of self, discarding w.

Truncation to Vec3 may also be performed by using self.xyz() or Vec3::from().

To truncate to Vec3A use Vec3A::from().

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

👎 Deprecated:

use ZERO constant instead

Creates a vector with all elements set to 0.0.

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

👎 Deprecated:

use ONE constant instead

Creates a vector with all elements set to 1.0.

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

Creates a vector with all elements set to v.

pub fn select(mask: BVec4A, if_true: Vec4, if_false: Vec4) -> Vec4[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: Vec4) -> f32[src]

Computes the dot product of self and other.

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

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

pub fn signum(self) -> Vec4[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) -> BVec4A[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: Vec4) -> f32[src]

Computes the Euclidean distance between two points in space.

pub fn distance_squared(self, other: Vec4) -> f32[src]

Compute the squared euclidean distance between two points in space.

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

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

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

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

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

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

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

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

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

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

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

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

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

Returns a vector with a length no more than max

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

Returns a vector with a length no less than min

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

Casts all elements of self to f64.

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

Casts all elements of self to i32.

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

Casts all elements of self to u32.

Trait Implementations

impl Add<Vec4> for Vec4[src]

type Output = Vec4

The resulting type after applying the + operator.

impl Add<Vec4> for Color

type Output = Color

The resulting type after applying the + operator.

impl AddAssign<Vec4> for Vec4[src]

impl AddAssign<Vec4> for Color

impl AsMut<[f32; 4]> for Vec4[src]

impl AsRef<[f32; 4]> for Vec4[src]

impl AsVertexFormats for Vec4

impl Byteable for Vec4

impl Clone for Vec4[src]

impl Copy for Vec4[src]

impl Debug for Vec4[src]

impl Default for Vec4[src]

impl Deref for Vec4[src]

type Target = XYZW<f32>

The resulting type after dereferencing.

impl DerefMut for Vec4[src]

impl<'de> Deserialize<'de> for Vec4[src]

impl Display for Vec4[src]

impl Div<Vec4> for Vec4[src]

type Output = Vec4

The resulting type after applying the / operator.

impl Div<f32> for Vec4[src]

type Output = Vec4

The resulting type after applying the / operator.

impl DivAssign<Vec4> for Vec4[src]

impl DivAssign<f32> for Vec4[src]

impl From<[f32; 4]> for Vec4[src]

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

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

impl From<Color> for Vec4

impl From<Quat> for Vec4[src]

impl From<Vec4> for __m128[src]

impl From<Vec4> for Quat[src]

impl From<Vec4> for [f32; 4][src]

impl From<Vec4> for Vec2[src]

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

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

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

impl From<Vec4> for Vec3A[src]

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

Creates a Vec3A from the x, y and z elements of self discarding w.

On architectures where SIMD is supported such as SSE2 on x86_64 this conversion is a noop.

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<Vec4> for Color

impl From<__m128> for Vec4[src]

impl GetTypeRegistration for Vec4

impl Index<usize> for Vec4[src]

type Output = f32

The returned type after indexing.

impl IndexMut<usize> for Vec4[src]

impl Mul<Vec4> for Mat4[src]

type Output = Vec4

The resulting type after applying the * operator.

impl Mul<Vec4> for Vec4[src]

type Output = Vec4

The resulting type after applying the * operator.

impl Mul<Vec4> for Color

type Output = Color

The resulting type after applying the * operator.

impl Mul<f32> for Vec4[src]

type Output = Vec4

The resulting type after applying the * operator.

impl MulAssign<Vec4> for Vec4[src]

impl MulAssign<Vec4> for Color

impl MulAssign<f32> for Vec4[src]

impl Neg for Vec4[src]

type Output = Vec4

The resulting type after applying the - operator.

impl PartialEq<Vec4> for Vec4[src]

impl PartialOrd<Vec4> for Vec4[src]

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

impl Reflect for Vec4

impl RenderResource for Vec4

impl Serialize for Vec4[src]

impl Sub<Vec4> for Vec4[src]

type Output = Vec4

The resulting type after applying the - operator.

impl SubAssign<Vec4> for Vec4[src]

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

impl Vec4Swizzles for Vec4[src]

type Vec2 = Vec2

type Vec3 = Vec3

Auto Trait Implementations

impl RefUnwindSafe for Vec4

impl Send for Vec4

impl Sync for Vec4

impl Unpin for Vec4

impl UnwindSafe for Vec4

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any

impl<T> AsBytes for T where
    T: Byteable

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

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

impl<T> Bytes for T where
    T: Byteable

impl<T> CloneAny for T where
    T: Any + Clone

impl<T> Component for T where
    T: 'static + Send + Sync

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> Downcast for T where
    T: Any

impl<T> Downcast<T> for T

impl<T> DowncastSync for T where
    T: Any + Send + Sync

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

impl<T> FromBytes for T where
    T: Byteable + Clone

impl<T> FromWorld for T where
    T: Default

impl<T> GetPath for T where
    T: Reflect

impl<T> Instrument for T[src]

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

impl<M> Measure for M where
    M: Debug + PartialOrd<M> + Add<M, Output = M> + Default + Clone
[src]

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

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

type Owned = T

The resulting type after obtaining ownership.

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

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.

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.

impl<T> TypeData for T where
    T: 'static + Send + Sync + Clone

impl<T> Upcast<T> for T

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,