[−][src]Struct bevy_math::f32::Vec4
A 4-dimensional vector.
This type is 16 byte aligned.
Implementations
impl Vec4
[src]
pub fn new(x: f32, y: f32, z: f32, w: f32) -> Vec4
[src]
Creates a new Vec4
.
pub fn zero() -> Vec4
[src]
Creates a new Vec4
with all elements set to 0.0
.
pub fn one() -> Vec4
[src]
Creates a new Vec4
with all elements set to 1.0
.
pub fn unit_x() -> Vec4
[src]
Creates a new Vec4
with values [x: 1.0, y: 0.0, z: 0.0, w: 0.0]
.
pub fn unit_y() -> Vec4
[src]
Creates a new Vec4
with values [x: 0.0, y: 1.0, z: 0.0, w: 0.0]
.
pub fn unit_z() -> Vec4
[src]
Creates a new Vec4
with values [x: 0.0, y: 0.0, z: 1.0, w: 0.0]
.
pub fn unit_w() -> Vec4
[src]
Creates a new Vec4
with values [x: 0.0, y: 0.0, z: 0.0, w: 1.0]
.
pub fn splat(v: f32) -> Vec4
[src]
Creates a new Vec4
with all elements set to v
.
pub fn truncate(self) -> Vec3A
[src]
Creates a Vec3A
from the first three elements of self
, removing w
.
Note that a Vec3A
is returned as both Vec4
and Vec3A
use SIMD storage so the
conversion is very cheap. If you need a Vec3
you can convert from Vec3A
using .into()
or Vec3::from
.
pub fn x(self) -> f32
[src]
Returns element x
.
pub fn y(self) -> f32
[src]
Returns element y
.
pub fn z(self) -> f32
[src]
Returns element z
.
pub fn w(self) -> f32
[src]
Returns element w
.
pub fn x_mut(&mut self) -> &mut f32
[src]
Returns a mutable reference to element x
.
pub fn y_mut(&mut self) -> &mut f32
[src]
Returns a mutable reference to element y
.
pub fn z_mut(&mut self) -> &mut f32
[src]
Returns a mutable reference to element z
.
pub fn w_mut(&mut self) -> &mut f32
[src]
Returns a mutable reference to element w
.
pub fn set_x(&mut self, x: f32)
[src]
Sets element x
.
pub fn set_y(&mut self, y: f32)
[src]
Sets element y
.
pub fn set_z(&mut self, z: f32)
[src]
Sets element z
.
pub fn set_w(&mut self, w: f32)
[src]
Sets element w
.
pub fn dot(self, other: Vec4) -> f32
[src]
Computes the 4D dot product of self
and other
.
pub fn length(self) -> f32
[src]
Computes the 4D length of self
.
pub fn length_squared(self) -> f32
[src]
Computes the squared 4D length of self
.
This is generally faster than Vec4::length()
as it avoids a square
root operation.
pub fn length_reciprocal(self) -> f32
[src]
Computes 1.0 / Vec4::length()
.
For valid results, self
must not be of length zero.
pub fn normalize(self) -> Vec4
[src]
Returns self
normalized to length 1.0.
For valid results, self
must not be of length zero.
pub fn min(self, other: Vec4) -> Vec4
[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), w: min(w1, w2)]
,
taking the minimum of each element individually.
pub fn max(self, other: Vec4) -> Vec4
[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), w: max(w1, w2)]
,
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, w)
.
pub fn max_element(self) -> f32
[src]
Returns the horizontal maximum of self
's elements.
In other words, this computes max(x, y, z, w)
.
pub fn cmpeq(self, other: Vec4) -> Vec4Mask
[src]
Performs a vertical ==
comparison between self
and other
,
returning a Vec4Mask
of the results.
In other words, this computes [x1 == x2, y1 == y2, z1 == z2, w1 == w2]
.
pub fn cmpne(self, other: Vec4) -> Vec4Mask
[src]
Performs a vertical !=
comparison between self
and other
,
returning a Vec4Mask
of the results.
In other words, this computes [x1 != x2, y1 != y2, z1 != z2, w1 != w2]
.
pub fn cmpge(self, other: Vec4) -> Vec4Mask
[src]
Performs a vertical >=
comparison between self
and other
,
returning a Vec4Mask
of the results.
In other words, this computes [x1 >= x2, y1 >= y2, z1 >= z2, w1 >= w2]
.
pub fn cmpgt(self, other: Vec4) -> Vec4Mask
[src]
Performs a vertical >
comparison between self
and other
,
returning a Vec4Mask
of the results.
In other words, this computes [x1 > x2, y1 > y2, z1 > z2, w1 > w2]
.
pub fn cmple(self, other: Vec4) -> Vec4Mask
[src]
Performs a vertical <=
comparison between self
and other
,
returning a Vec4Mask
of the results.
In other words, this computes [x1 <= x2, y1 <= y2, z1 <= z2, w1 <= w2]
.
pub fn cmplt(self, other: Vec4) -> Vec4Mask
[src]
Performs a vertical <
comparison between self
and other
,
returning a Vec4Mask
of the results.
In other words, this computes [x1 < x2, y1 < y2, z1 < z2, w1 < w2]
.
pub fn from_slice_unaligned(slice: &[f32]) -> Vec4
[src]
Creates a new Vec4
from the first four values in slice
.
Panics
Panics if slice
is less than four elements long.
pub fn write_to_slice_unaligned(self, slice: &mut [f32])
[src]
Writes the elements of self
to the first four elements in slice
.
Panics
Panics if slice
is less than four elements long.
pub fn abs(self) -> Vec4
[src]
Returns a new Vec4
containing the absolute value of each element of the original
Vec4
.
pub fn round(self) -> Vec4
[src]
pub fn floor(self) -> Vec4
[src]
pub fn ceil(self) -> Vec4
[src]
pub fn sign(self) -> Vec4
[src]
Returns a new Vec4
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
pub fn reciprocal(self) -> Vec4
[src]
Computes the reciprocal 1.0/n
of each element, returning the
results in a new Vec4
.
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 is_normalized(self) -> bool
[src]
Returns whether self
is length 1.0
or not.
Uses a precision threshold of 1e-6
.
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 Vec4
'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/
Trait Implementations
impl Add<Vec4> for Vec4
[src]
type Output = Vec4
The resulting type after applying the +
operator.
fn add(self, other: Vec4) -> Vec4
[src]
impl AddAssign<Vec4> for Vec4
[src]
fn add_assign(&mut self, other: Vec4)
[src]
impl AsMut<[f32; 4]> for Vec4
[src]
impl AsRef<[f32; 4]> for Vec4
[src]
impl Clone for Vec4
[src]
impl Copy for Vec4
[src]
impl Debug for Vec4
[src]
impl Default for Vec4
[src]
impl<'de> Deserialize<'de> for Vec4
[src]
fn deserialize<D>(
deserializer: D
) -> Result<Vec4, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
[src]
deserializer: D
) -> Result<Vec4, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
impl Display for Vec4
[src]
impl Div<Vec4> for Vec4
[src]
type Output = Vec4
The resulting type after applying the /
operator.
fn div(self, other: Vec4) -> Vec4
[src]
impl Div<f32> for Vec4
[src]
type Output = Vec4
The resulting type after applying the /
operator.
fn div(self, other: f32) -> Vec4
[src]
impl DivAssign<Vec4> for Vec4
[src]
fn div_assign(&mut self, other: Vec4)
[src]
impl DivAssign<f32> for Vec4
[src]
fn div_assign(&mut self, other: f32)
[src]
impl From<[f32; 4]> for Vec4
[src]
impl From<(f32, f32, f32, f32)> for Vec4
[src]
impl From<Quat> for Vec4
[src]
impl From<Vec4> for Quat
[src]
impl From<__m128> for Vec4
[src]
impl Index<usize> for Vec4
[src]
type Output = f32
The returned type after indexing.
fn index(&self, index: usize) -> &<Vec4 as Index<usize>>::Output
[src]
impl IndexMut<usize> for Vec4
[src]
impl Mul<Vec4> for Vec4
[src]
type Output = Vec4
The resulting type after applying the *
operator.
fn mul(self, other: Vec4) -> Vec4
[src]
impl Mul<Vec4> for Mat4
[src]
type Output = Vec4
The resulting type after applying the *
operator.
fn mul(self, other: Vec4) -> Vec4
[src]
impl Mul<f32> for Vec4
[src]
type Output = Vec4
The resulting type after applying the *
operator.
fn mul(self, other: f32) -> Vec4
[src]
impl MulAssign<Vec4> for Vec4
[src]
fn mul_assign(&mut self, other: Vec4)
[src]
impl MulAssign<f32> for Vec4
[src]
fn mul_assign(&mut self, other: f32)
[src]
impl Neg for Vec4
[src]
impl PartialEq<Vec4> for Vec4
[src]
impl PartialOrd<Vec4> for Vec4
[src]
fn partial_cmp(&self, other: &Vec4) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for Vec4
[src]
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
[src]
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
impl Sub<Vec4> for Vec4
[src]
type Output = Vec4
The resulting type after applying the -
operator.
fn sub(self, other: Vec4) -> Vec4
[src]
impl SubAssign<Vec4> for Vec4
[src]
fn sub_assign(&mut self, other: Vec4)
[src]
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]
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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
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.
fn to_owned(&self) -> T
[src]
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.
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>,