#[repr(C, align(16))]pub struct Vector4 {
pub data: __m128,
}
Expand description
A vector of 4 floats (x,y,z,w).
Fields§
§data: __m128
Implementations§
Source§impl Vector4
impl Vector4
Sourcepub fn new(x: f32, y: f32, z: f32, w: f32) -> Vector4
pub fn new(x: f32, y: f32, z: f32, w: f32) -> Vector4
Construct a new vector from f32 components.
Sourcepub fn set<T: Into<FloatVector>>(value: T) -> Vector4
pub fn set<T: Into<FloatVector>>(value: T) -> Vector4
Set all values of the vector to the same f32 value.
Sourcepub fn x(self) -> FloatVector
pub fn x(self) -> FloatVector
Get the x value of the vector, broadcast to all components as a FloatVector (xxxx).
Sourcepub fn y(self) -> FloatVector
pub fn y(self) -> FloatVector
Get the y value of the vector, broadcast to all components as a FloatVector (yyyy).
Sourcepub fn z(self) -> FloatVector
pub fn z(self) -> FloatVector
Get the z value of the vector, broadcast to all components as a FloatVector (zzzz).
Sourcepub fn w(self) -> FloatVector
pub fn w(self) -> FloatVector
Get the w value of the vector, broadcast to all components as a FloatVector (wwww).
Sourcepub fn load(raw: &RawVector_f32) -> Vector4
pub fn load(raw: &RawVector_f32) -> Vector4
Load a value from aligned memory.
Sourcepub fn store(self, dst: &mut RawVector_f32)
pub fn store(self, dst: &mut RawVector_f32)
Store a value to aligned memory.
Sourcepub fn set_x<T: Into<FloatVector>>(&mut self, value: T)
pub fn set_x<T: Into<FloatVector>>(&mut self, value: T)
Set the x value of this vector, leaving the other components unchanged.
Sourcepub fn set_y<T: Into<FloatVector>>(&mut self, value: T)
pub fn set_y<T: Into<FloatVector>>(&mut self, value: T)
Set the y value of this vector, leaving the other components unchanged.
Sourcepub fn set_z<T: Into<FloatVector>>(&mut self, value: T)
pub fn set_z<T: Into<FloatVector>>(&mut self, value: T)
Set the z value of this vector, leaving the other components unchanged.
Sourcepub fn set_w<T: Into<FloatVector>>(&mut self, value: T)
pub fn set_w<T: Into<FloatVector>>(&mut self, value: T)
Set the w value of this vector, leaving the other components unchanged.
Sourcepub fn dot(self, v2: Vector4) -> FloatVector
pub fn dot(self, v2: Vector4) -> FloatVector
Compute the 4 element dot-product, and return it as a broadcast FloatVector.
Sourcepub fn add(self, v2: Vector4) -> Vector4
pub fn add(self, v2: Vector4) -> Vector4
Compute the sum of two vectors and return it as a new vector.
Sourcepub fn mul(self, v2: Vector4) -> Vector4
pub fn mul(self, v2: Vector4) -> Vector4
Multiply two vectors component-wise, and return it as a new vector.
(x1 * x2, y1 * y2, z1 * z2, w1 * w2)
Sourcepub fn div(self, v2: Vector4) -> Vector4
pub fn div(self, v2: Vector4) -> Vector4
Divide two vectors component-wise, and return it as a new vector.
(x1 / x2, y1 / y2, z1 / z2, w1 / w2)
Sourcepub fn mul_add(self, v2: Vector4, v3: Vector4) -> Vector4
pub fn mul_add(self, v2: Vector4, v3: Vector4) -> Vector4
Fused Multiply Add. Result = (a * b) + c.
Sourcepub fn mul_sub(self, v2: Vector4, v3: Vector4) -> Vector4
pub fn mul_sub(self, v2: Vector4, v3: Vector4) -> Vector4
Fused Multiply Sub. Result = (a * b) - c.
Sourcepub fn neg_mul_add(self, v2: Vector4, v3: Vector4) -> Vector4
pub fn neg_mul_add(self, v2: Vector4, v3: Vector4) -> Vector4
Negated Fused Multiply Add. Result = -(a * b) + c.
Sourcepub fn neg_mul_sub(self, v2: Vector4, v3: Vector4) -> Vector4
pub fn neg_mul_sub(self, v2: Vector4, v3: Vector4) -> Vector4
Negated Fused Multiply Sub. Result = -(a * b) - c.
Sourcepub fn and<T: SIMDVector4>(self, v2: T) -> Vector4
pub fn and<T: SIMDVector4>(self, v2: T) -> Vector4
Compute the bitwise AND of two vectors. This function treats inputs as binary data, and doesn’t perform any conversions.
Sourcepub fn or<T: SIMDVector4>(self, v2: T) -> Vector4
pub fn or<T: SIMDVector4>(self, v2: T) -> Vector4
Compute the bitwise OR of two vectors. This function treats inputs as binary data, and doesn’t perform any conversions.
Sourcepub fn andnot<T: SIMDVector4>(self, v2: T) -> Vector4
pub fn andnot<T: SIMDVector4>(self, v2: T) -> Vector4
Compute the bitwise ANDNOT of two vectors. This function treats inputs as binary data, and doesn’t perform any conversions.
Sourcepub fn xor<T: SIMDVector4>(self, v2: T) -> Vector4
pub fn xor<T: SIMDVector4>(self, v2: T) -> Vector4
Compute the bitwise XOR of two vectors. This function treats inputs as binary data, and doesn’t perform any conversions.
Sourcepub fn equal(self, v2: Vector4) -> Vector4Bool
pub fn equal(self, v2: Vector4) -> Vector4Bool
Equals, computed component-wise. This compares bits, and is exact.
Sourcepub fn not_equal(self, v2: Vector4) -> Vector4Bool
pub fn not_equal(self, v2: Vector4) -> Vector4Bool
NotEquals, computed component-wise. This compares bits, and is exact.
Sourcepub fn greater_equal(self, v2: Vector4) -> Vector4Bool
pub fn greater_equal(self, v2: Vector4) -> Vector4Bool
Greater than or equal to, computed component-wise. This compares bits, and is exact.
Sourcepub fn greater(self, v2: Vector4) -> Vector4Bool
pub fn greater(self, v2: Vector4) -> Vector4Bool
Greater than, computed component-wise. This compares bits, and is exact.
Sourcepub fn less_equal(self, v2: Vector4) -> Vector4Bool
pub fn less_equal(self, v2: Vector4) -> Vector4Bool
Less than or equal to, computed component-wise. This compares bits, and is exact.
Sourcepub fn less(self, v2: Vector4) -> Vector4Bool
pub fn less(self, v2: Vector4) -> Vector4Bool
Less than, computed component-wise. This compares bits, and is exact.
Sourcepub fn approx_equal(self, v2: Vector4) -> Vector4Bool
pub fn approx_equal(self, v2: Vector4) -> Vector4Bool
Relative and absolute epsilon comparison.
Uses machine epsilon as absolute, and 4*machine epsilon for relative.
return abs(a - b) <= max(machine_epsilon, (max( abs(a), abs(b) ) * relative_epsilon);
Adapted from Knuth.
https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
Sourcepub fn definitely_greater(self, v2: Vector4) -> Vector4Bool
pub fn definitely_greater(self, v2: Vector4) -> Vector4Bool
Adapted from Knuth with an added absolute epsilon return (a - b) > max(machine_epsilon, (max( abs(a), abs(b) ) * relative_epsilon);
Sourcepub fn definitely_less(self, v2: Vector4) -> Vector4Bool
pub fn definitely_less(self, v2: Vector4) -> Vector4Bool
Adapted from Knuth with an added absolute epsilon return (a - b) > max(machine_epsilon, (max( abs(a), abs(b) ) * relative_epsilon);
Sourcepub fn copysign(self, v2: Vector4) -> Vector4
pub fn copysign(self, v2: Vector4) -> Vector4
Take the magnitude of the first argument (self), and use the sign of the second argument to produce a new vector
Sourcepub fn round(self) -> Vector4
pub fn round(self) -> Vector4
Round to nearest even function. Returns signed 0 when applicable.
Sourcepub fn floor_to_int(self) -> Vector4Int
pub fn floor_to_int(self) -> Vector4Int
Convert to an integer vector using the floor function.
Sourcepub fn ceil_to_int(self) -> Vector4Int
pub fn ceil_to_int(self) -> Vector4Int
Convert to an integer vector using the ceil function.
Sourcepub fn round_to_int(self) -> Vector4Int
pub fn round_to_int(self) -> Vector4Int
Convert to an integer vector using the round function.
Sourcepub fn truncate_to_int(self) -> Vector4Int
pub fn truncate_to_int(self) -> Vector4Int
Convert to an integer vector using the truncate function.
Sourcepub fn frac(self) -> Vector4
pub fn frac(self) -> Vector4
Compute the fractional component of each component Result = X - Floor(x)
pub fn atan2(self, x: Vector4) -> Vector4
pub fn horizontal_min(self) -> FloatVector
pub fn horizontal_max(self) -> FloatVector
Sourcepub fn select(self, v2: Vector4, mask: Vector4Bool) -> Vector4
pub fn select(self, v2: Vector4, mask: Vector4Bool) -> Vector4
Choose component wise between A and B based on the mask. False = A, True = B.
Sourcepub fn lerp<T: Into<FloatVector>>(self, v2: Vector4, t: T) -> Vector4
pub fn lerp<T: Into<FloatVector>>(self, v2: Vector4, t: T) -> Vector4
Linear interpolate from a to b based on a float.
Sourcepub fn normalize(self) -> Vector4
pub fn normalize(self) -> Vector4
Normalize the vector. Returns a zero vector if the result would be infinity or NAN.
Sourcepub fn normalize_length(self) -> (Vector4, FloatVector)
pub fn normalize_length(self) -> (Vector4, FloatVector)
Normalize the vector. Returns a zero vector if the result would be infinity or NAN. Also returns the length of the vector prior to normalization.
Sourcepub fn sqr_magnitude(self) -> FloatVector
pub fn sqr_magnitude(self) -> FloatVector
The square magnitude of the vector. Equal to Dot(self, self).
Sourcepub fn magnitude(self) -> FloatVector
pub fn magnitude(self) -> FloatVector
The magnitude of the vector. Equal to Sqrt(Dot(self, self)).
pub fn xxxx(self) -> Vector4
pub fn xxxy(self) -> Vector4
pub fn xxxz(self) -> Vector4
pub fn xxxw(self) -> Vector4
pub fn xxyx(self) -> Vector4
pub fn xxyy(self) -> Vector4
pub fn xxyz(self) -> Vector4
pub fn xxyw(self) -> Vector4
pub fn xxzx(self) -> Vector4
pub fn xxzy(self) -> Vector4
pub fn xxzz(self) -> Vector4
pub fn xxzw(self) -> Vector4
pub fn xxwx(self) -> Vector4
pub fn xxwy(self) -> Vector4
pub fn xxwz(self) -> Vector4
pub fn xxww(self) -> Vector4
pub fn xyxx(self) -> Vector4
pub fn xyxy(self) -> Vector4
pub fn xyxz(self) -> Vector4
pub fn xyxw(self) -> Vector4
pub fn xyyx(self) -> Vector4
pub fn xyyy(self) -> Vector4
pub fn xyyz(self) -> Vector4
pub fn xyyw(self) -> Vector4
pub fn xyzx(self) -> Vector4
pub fn xyzy(self) -> Vector4
pub fn xyzz(self) -> Vector4
pub fn xyzw(self) -> Vector4
pub fn xywx(self) -> Vector4
pub fn xywy(self) -> Vector4
pub fn xywz(self) -> Vector4
pub fn xyww(self) -> Vector4
pub fn xzxx(self) -> Vector4
pub fn xzxy(self) -> Vector4
pub fn xzxz(self) -> Vector4
pub fn xzxw(self) -> Vector4
pub fn xzyx(self) -> Vector4
pub fn xzyy(self) -> Vector4
pub fn xzyz(self) -> Vector4
pub fn xzyw(self) -> Vector4
pub fn xzzx(self) -> Vector4
pub fn xzzy(self) -> Vector4
pub fn xzzz(self) -> Vector4
pub fn xzzw(self) -> Vector4
pub fn xzwx(self) -> Vector4
pub fn xzwy(self) -> Vector4
pub fn xzwz(self) -> Vector4
pub fn xzww(self) -> Vector4
pub fn xwxx(self) -> Vector4
pub fn xwxy(self) -> Vector4
pub fn xwxz(self) -> Vector4
pub fn xwxw(self) -> Vector4
pub fn xwyx(self) -> Vector4
pub fn xwyy(self) -> Vector4
pub fn xwyz(self) -> Vector4
pub fn xwyw(self) -> Vector4
pub fn xwzx(self) -> Vector4
pub fn xwzy(self) -> Vector4
pub fn xwzz(self) -> Vector4
pub fn xwzw(self) -> Vector4
pub fn xwwx(self) -> Vector4
pub fn xwwy(self) -> Vector4
pub fn xwwz(self) -> Vector4
pub fn xwww(self) -> Vector4
pub fn yxxx(self) -> Vector4
pub fn yxxy(self) -> Vector4
pub fn yxxz(self) -> Vector4
pub fn yxxw(self) -> Vector4
pub fn yxyx(self) -> Vector4
pub fn yxyy(self) -> Vector4
pub fn yxyz(self) -> Vector4
pub fn yxyw(self) -> Vector4
pub fn yxzx(self) -> Vector4
pub fn yxzy(self) -> Vector4
pub fn yxzz(self) -> Vector4
pub fn yxzw(self) -> Vector4
pub fn yxwx(self) -> Vector4
pub fn yxwy(self) -> Vector4
pub fn yxwz(self) -> Vector4
pub fn yxww(self) -> Vector4
pub fn yyxx(self) -> Vector4
pub fn yyxy(self) -> Vector4
pub fn yyxz(self) -> Vector4
pub fn yyxw(self) -> Vector4
pub fn yyyx(self) -> Vector4
pub fn yyyy(self) -> Vector4
pub fn yyyz(self) -> Vector4
pub fn yyyw(self) -> Vector4
pub fn yyzx(self) -> Vector4
pub fn yyzy(self) -> Vector4
pub fn yyzz(self) -> Vector4
pub fn yyzw(self) -> Vector4
pub fn yywx(self) -> Vector4
pub fn yywy(self) -> Vector4
pub fn yywz(self) -> Vector4
pub fn yyww(self) -> Vector4
pub fn yzxx(self) -> Vector4
pub fn yzxy(self) -> Vector4
pub fn yzxz(self) -> Vector4
pub fn yzxw(self) -> Vector4
pub fn yzyx(self) -> Vector4
pub fn yzyy(self) -> Vector4
pub fn yzyz(self) -> Vector4
pub fn yzyw(self) -> Vector4
pub fn yzzx(self) -> Vector4
pub fn yzzy(self) -> Vector4
pub fn yzzz(self) -> Vector4
pub fn yzzw(self) -> Vector4
pub fn yzwx(self) -> Vector4
pub fn yzwy(self) -> Vector4
pub fn yzwz(self) -> Vector4
pub fn yzww(self) -> Vector4
pub fn ywxx(self) -> Vector4
pub fn ywxy(self) -> Vector4
pub fn ywxz(self) -> Vector4
pub fn ywxw(self) -> Vector4
pub fn ywyx(self) -> Vector4
pub fn ywyy(self) -> Vector4
pub fn ywyz(self) -> Vector4
pub fn ywyw(self) -> Vector4
pub fn ywzx(self) -> Vector4
pub fn ywzy(self) -> Vector4
pub fn ywzz(self) -> Vector4
pub fn ywzw(self) -> Vector4
pub fn ywwx(self) -> Vector4
pub fn ywwy(self) -> Vector4
pub fn ywwz(self) -> Vector4
pub fn ywww(self) -> Vector4
pub fn zxxx(self) -> Vector4
pub fn zxxy(self) -> Vector4
pub fn zxxz(self) -> Vector4
pub fn zxxw(self) -> Vector4
pub fn zxyx(self) -> Vector4
pub fn zxyy(self) -> Vector4
pub fn zxyz(self) -> Vector4
pub fn zxyw(self) -> Vector4
pub fn zxzx(self) -> Vector4
pub fn zxzy(self) -> Vector4
pub fn zxzz(self) -> Vector4
pub fn zxzw(self) -> Vector4
pub fn zxwx(self) -> Vector4
pub fn zxwy(self) -> Vector4
pub fn zxwz(self) -> Vector4
pub fn zxww(self) -> Vector4
pub fn zyxx(self) -> Vector4
pub fn zyxy(self) -> Vector4
pub fn zyxz(self) -> Vector4
pub fn zyxw(self) -> Vector4
pub fn zyyx(self) -> Vector4
pub fn zyyy(self) -> Vector4
pub fn zyyz(self) -> Vector4
pub fn zyyw(self) -> Vector4
pub fn zyzx(self) -> Vector4
pub fn zyzy(self) -> Vector4
pub fn zyzz(self) -> Vector4
pub fn zyzw(self) -> Vector4
pub fn zywx(self) -> Vector4
pub fn zywy(self) -> Vector4
pub fn zywz(self) -> Vector4
pub fn zyww(self) -> Vector4
pub fn zzxx(self) -> Vector4
pub fn zzxy(self) -> Vector4
pub fn zzxz(self) -> Vector4
pub fn zzxw(self) -> Vector4
pub fn zzyx(self) -> Vector4
pub fn zzyy(self) -> Vector4
pub fn zzyz(self) -> Vector4
pub fn zzyw(self) -> Vector4
pub fn zzzx(self) -> Vector4
pub fn zzzy(self) -> Vector4
pub fn zzzz(self) -> Vector4
pub fn zzzw(self) -> Vector4
pub fn zzwx(self) -> Vector4
pub fn zzwy(self) -> Vector4
pub fn zzwz(self) -> Vector4
pub fn zzww(self) -> Vector4
pub fn zwxx(self) -> Vector4
pub fn zwxy(self) -> Vector4
pub fn zwxz(self) -> Vector4
pub fn zwxw(self) -> Vector4
pub fn zwyx(self) -> Vector4
pub fn zwyy(self) -> Vector4
pub fn zwyz(self) -> Vector4
pub fn zwyw(self) -> Vector4
pub fn zwzx(self) -> Vector4
pub fn zwzy(self) -> Vector4
pub fn zwzz(self) -> Vector4
pub fn zwzw(self) -> Vector4
pub fn zwwx(self) -> Vector4
pub fn zwwy(self) -> Vector4
pub fn zwwz(self) -> Vector4
pub fn zwww(self) -> Vector4
pub fn wxxx(self) -> Vector4
pub fn wxxy(self) -> Vector4
pub fn wxxz(self) -> Vector4
pub fn wxxw(self) -> Vector4
pub fn wxyx(self) -> Vector4
pub fn wxyy(self) -> Vector4
pub fn wxyz(self) -> Vector4
pub fn wxyw(self) -> Vector4
pub fn wxzx(self) -> Vector4
pub fn wxzy(self) -> Vector4
pub fn wxzz(self) -> Vector4
pub fn wxzw(self) -> Vector4
pub fn wxwx(self) -> Vector4
pub fn wxwy(self) -> Vector4
pub fn wxwz(self) -> Vector4
pub fn wxww(self) -> Vector4
pub fn wyxx(self) -> Vector4
pub fn wyxy(self) -> Vector4
pub fn wyxz(self) -> Vector4
pub fn wyxw(self) -> Vector4
pub fn wyyx(self) -> Vector4
pub fn wyyy(self) -> Vector4
pub fn wyyz(self) -> Vector4
pub fn wyyw(self) -> Vector4
pub fn wyzx(self) -> Vector4
pub fn wyzy(self) -> Vector4
pub fn wyzz(self) -> Vector4
pub fn wyzw(self) -> Vector4
pub fn wywx(self) -> Vector4
pub fn wywy(self) -> Vector4
pub fn wywz(self) -> Vector4
pub fn wyww(self) -> Vector4
pub fn wzxx(self) -> Vector4
pub fn wzxy(self) -> Vector4
pub fn wzxz(self) -> Vector4
pub fn wzxw(self) -> Vector4
pub fn wzyx(self) -> Vector4
pub fn wzyy(self) -> Vector4
pub fn wzyz(self) -> Vector4
pub fn wzyw(self) -> Vector4
pub fn wzzx(self) -> Vector4
pub fn wzzy(self) -> Vector4
pub fn wzzz(self) -> Vector4
pub fn wzzw(self) -> Vector4
pub fn wzwx(self) -> Vector4
pub fn wzwy(self) -> Vector4
pub fn wzwz(self) -> Vector4
pub fn wzww(self) -> Vector4
pub fn wwxx(self) -> Vector4
pub fn wwxy(self) -> Vector4
pub fn wwxz(self) -> Vector4
pub fn wwxw(self) -> Vector4
pub fn wwyx(self) -> Vector4
pub fn wwyy(self) -> Vector4
pub fn wwyz(self) -> Vector4
pub fn wwyw(self) -> Vector4
pub fn wwzx(self) -> Vector4
pub fn wwzy(self) -> Vector4
pub fn wwzz(self) -> Vector4
pub fn wwzw(self) -> Vector4
pub fn wwwx(self) -> Vector4
pub fn wwwy(self) -> Vector4
pub fn wwwz(self) -> Vector4
pub fn wwww(self) -> Vector4
Trait Implementations§
Source§impl AddAssign for Vector4
impl AddAssign for Vector4
Source§fn add_assign(&mut self, other: Vector4)
fn add_assign(&mut self, other: Vector4)
+=
operation. Read moreSource§impl Div<Vector4> for FloatVector
impl Div<Vector4> for FloatVector
Source§impl<T: Into<FloatVector>> DivAssign<T> for Vector4
impl<T: Into<FloatVector>> DivAssign<T> for Vector4
Source§fn div_assign(&mut self, _rhs: T)
fn div_assign(&mut self, _rhs: T)
/=
operation. Read moreSource§impl From<FloatVector> for Vector4
impl From<FloatVector> for Vector4
Source§fn from(v: FloatVector) -> Vector4
fn from(v: FloatVector) -> Vector4
Source§impl From<Quaternion> for Vector4
impl From<Quaternion> for Vector4
Source§fn from(v: Quaternion) -> Vector4
fn from(v: Quaternion) -> Vector4
Source§impl From<Vector4> for Quaternion
impl From<Vector4> for Quaternion
Source§fn from(v: Vector4) -> Quaternion
fn from(v: Vector4) -> Quaternion
Source§impl From<Vector4> for Vector4Int
impl From<Vector4> for Vector4Int
Source§fn from(v: Vector4) -> Vector4Int
fn from(v: Vector4) -> Vector4Int
Source§impl From<Vector4Int> for Vector4
impl From<Vector4Int> for Vector4
Source§fn from(v: Vector4Int) -> Vector4
fn from(v: Vector4Int) -> Vector4
Source§impl Mul<Vector4> for FloatVector
impl Mul<Vector4> for FloatVector
Source§impl<T: Into<FloatVector>> MulAssign<T> for Vector4
impl<T: Into<FloatVector>> MulAssign<T> for Vector4
Source§fn mul_assign(&mut self, _rhs: T)
fn mul_assign(&mut self, _rhs: T)
*=
operation. Read moreSource§impl SubAssign for Vector4
impl SubAssign for Vector4
Source§fn sub_assign(&mut self, other: Vector4)
fn sub_assign(&mut self, other: Vector4)
-=
operation. Read more