pub struct Vector<const N: usize, T, A: Alignment>(/* private fields */)
where
Length<N>: SupportedLength,
T: Scalar;Expand description
An N-dimensional vector of type T.
A controls SIMD alignment and is either Unaligned or Aligned. See
Alignment for more details.
§Type aliases
Vec2<T>forVector<2, T, Unaligned>.Vec3<T>forVector<3, T, Unaligned>.Vec4<T>forVector<4, T, Unaligned>.Vec2A<T>forVector<2, T, Aligned>.Vec3A<T>forVector<3, T, Aligned>.Vec4A<T>forVector<4, T, Aligned>.
§Fields
-
x: T(the first element of the vector, exists for lengths2,3,4) -
y: T(the second element of the vector, exists for lengths2,3,4) -
z: T(the third element of the vector, exists for lengths3,4) -
w: T(the fourth element of the vector, exists for length4)
Note that these fields are only exposed by implementing Deref and
DerefMut.
§Memory layout
Vector<N, T, A> contains N consecutive values of T followed by
optional padding.
Vector<N, T, Unaligned> has the alignment of T and has no padding.
Vector<N, T, Aligned> may have higher alignment than T. Vec2A<T>
and Vec4A<T> have no padding. Vec3A<T> may have one padding element.
Padding is fully initialized and accepts all bit patterns. Unless T
accepts all bit patterns, it is not sound to assume padding contains valid
values of T.
Implementations§
Source§impl<const N: usize, A: Alignment> Vector<N, bool, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, bool, A>where
Length<N>: SupportedLength,
Sourcepub fn all(self) -> bool
pub fn all(self) -> bool
Returns true if all elements of self are true.
§Examples
let a = Vec3::new(true, true, false).all();
assert_eq!(a, false);
let a = Vec3::new(true, true, true).all();
assert_eq!(a, true);Sourcepub fn any(self) -> bool
pub fn any(self) -> bool
Returns true if any element of self is true.
§Examples
let a = Vec3::new(true, true, false).any();
assert_eq!(a, true);
let a = Vec3::new(false, false, false).any();
assert_eq!(a, false);Sourcepub fn select<T: Scalar>(
self,
if_true: Vector<N, T, A>,
if_false: Vector<N, T, A>,
) -> Vector<N, T, A>
pub fn select<T: Scalar>( self, if_true: Vector<N, T, A>, if_false: Vector<N, T, A>, ) -> Vector<N, T, A>
Selects between the elements of if_true and if_false based on the
boolean elements of self.
§Examples
let a = Vec4::new(true, false, false, true);
let b = Vec4::new(1, 2, 3, 4);
let c = Vec4::new(-1, -2, -3, -4);
let d = a.select(b, c);
assert_eq!(d, Vec4::new(1, -2, -3, 4));Source§impl<const N: usize, T, A: Alignment> Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Vector<N, T, A>
Sourcepub const NEG_INFINITY: Self
pub const NEG_INFINITY: Self
A vector with all elements set to NEG_INFINITY.
Sourcepub fn is_nan(self) -> bool
pub fn is_nan(self) -> bool
Returns true if any element is NaN.
§Examples
let nan = Vec3::new(1.0, 2.0, f32::NAN);
let f = Vec3::new(1.0, 2.0, 3.0);
assert!(nan.is_nan());
assert!(!f.is_nan());Sourcepub fn nan_mask(self) -> Mask<N, T, A>
pub fn nan_mask(self) -> Mask<N, T, A>
Returns a vector mask where each element is true if the corresponding
element of self is NaN.
Equivalent to (self.x.is_nan(), self.y.is_nan(), ...).
§Examples
let vector = Vec3::new(1.0, 2.0, f32::NAN);
let mask = vector.nan_mask();
assert_eq!(mask, Mask3::new(false, false, true));Sourcepub fn is_finite(self) -> bool
pub fn is_finite(self) -> bool
Returns true if all elements are neither infinite nor NaN.
§Examples
let f = Vec3::new(1.0, 2.0, 3.0);
let inf = Vec3::new(1.0, f32::INFINITY, 3.0);
let neg_inf = Vec3::new(1.0, f32::NEG_INFINITY, 3.0);
let nan = Vec3::new(1.0, f32::NEG_INFINITY, 3.0);
assert!(f.is_finite());
assert!(!inf.is_finite());
assert!(!neg_inf.is_finite());
assert!(!nan.is_finite());Sourcepub fn finite_mask(self) -> Mask<N, T, A>
pub fn finite_mask(self) -> Mask<N, T, A>
Returns a vector mask where each element is true if the corresponding
element of self is neither infinite nor NaN.
Equivalent to (self.x.is_finite(), self.y.is_finite(), ...).
§Examples
let vector = Vec3::new(1.0, f32::INFINITY, f32::NAN);
let mask = vector.finite_mask();
assert_eq!(mask, Mask3::new(true, false, false));Sourcepub fn sign_positive_mask(self) -> Mask<N, T, A>
pub fn sign_positive_mask(self) -> Mask<N, T, A>
Returns a vector mask where each element is true if the corresponding
element of self has a positive sign, including +0.0, NaNs with
positive sign bit and positive infinity.
Equivalent to
(self.x.is_sign_positive(), self.y.is_sign_positive(), ...).
§Examples
let vector = Vec4::new(1.0, -2.0, -3.0, f32::INFINITY);
let mask = vector.sign_positive_mask();
assert_eq!(mask, Mask4::new(true, false, false, true));Sourcepub fn sign_negative_mask(self) -> Mask<N, T, A>
pub fn sign_negative_mask(self) -> Mask<N, T, A>
Returns a vector mask where each element is true if the corresponding
element of self has a negative sign, including -0.0, NaNs with
negative sign bit and negative infinity.
Equivalent to
(self.x.is_sign_negative(), self.y.is_sign_negative(), ...).
§Examples
let vector = Vec4::new(1.0, -2.0, 3.0, f32::NEG_INFINITY);
let mask = vector.sign_negative_mask();
assert_eq!(mask, Mask4::new(false, true, false, true));Sourcepub fn recip(self) -> Self
pub fn recip(self) -> Self
Returns the element-wise reciprocal (inverse) of a vector, 1 / self.
§Examples
let vector = Vec3::new(2.0, 3.0, 4.0);
let recip = vector.recip();
let div = Vec3::ONE / vector;
assert_eq!(recip, div);Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
This is not consistent with IEEE semantics in regards to NaN propagation
and handling of -0.0.
§Panics
When debug assertions are enabled:
Panics if any element is NaN.
§Examples
let a = Vec4::new(1.0, 5.0, 3.0, 0.0);
let b = Vec4::new(3.0, 2.0, 7.0, -1.0);
let max = a.max(b);
assert_eq!(max, Vec4::new(3.0, 5.0, 7.0, 0.0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
This is not consistent with IEEE semantics in regards to NaN propagation
and handling of -0.0.
§Panics
When debug assertions are enabled:
Panics if any element is NaN.
§Examples
let a = Vec4::new(1.0, 5.0, 3.0, 0.0);
let b = Vec4::new(3.0, 2.0, 7.0, -1.0);
let min = a.min(b);
assert_eq!(min, Vec4::new(1.0, 2.0, 3.0, -1.0));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
This is not consistent with IEEE semantics in regards to NaN propagation
and handling of -0.0.
§Panics
When debug assertions are enabled:
Panics if any element is NaN, or if any element of min is greater than
the corresponding element of max.
§Examples
let vector = Vec4::new(1.0, 2.0, 3.0, 0.0);
let min = Vec4::new(0.0, 5.0, 1.0, -2.0);
let max = Vec4::new(3.0, 6.0, 2.0, -1.0);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1.0, 5.0, 2.0, -1.0));Sourcepub fn max_element(self) -> T
pub fn max_element(self) -> T
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
This is not consistent with IEEE semantics in regards to NaN propagation
and handling of -0.0.
§Panics
When debug assertions are enabled:
Panics if any element is NaN.
§Examples
let vector = Vec3::new(-1.0, 7.0, 3.0);
assert_eq!(vector.max_element(), 7.0);Sourcepub fn min_element(self) -> T
pub fn min_element(self) -> T
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
This is not consistent with IEEE semantics in regards to NaN propagation
and handling of -0.0.
§Panics
When debug assertions are enabled:
Panics if any element is NaN.
§Examples
let vector = Vec3::new(7.0, -1.0, 3.0);
assert_eq!(vector.min_element(), -1.0);Sourcepub fn abs(self) -> Self
pub fn abs(self) -> Self
Returns the absolute values of elements of self.
Equivalent to (self.x.abs(), self.y.abs(), ...).
§Examples
let vector = Vec3::new(7.0, -1.0, -3.0);
assert_eq!(vector.abs(), Vec3::new(7.0, 1.0, 3.0));Sourcepub fn signum(self) -> Self
pub fn signum(self) -> Self
Returns the signum of the elements of self.
Equivalent to (self.x.signum(), self.y.signum(), ...).
For each element:
1.0if the element is positive,+0.0orINFINITY-1.0if the element is negative,-0.0orNEG_INFINITY- NaN if the element is NaN
§Examples
let vector = Vec4::new(7.0, -1.0, -3.0, f32::NAN);
assert_eq!(vector.signum().x, 1.0);
assert_eq!(vector.signum().y, -1.0);
assert_eq!(vector.signum().z, -1.0);
assert!(vector.signum().w.is_nan());Sourcepub fn copysign(self, sign: Self) -> Self
pub fn copysign(self, sign: Self) -> Self
Returns a vector with the element magnitudes of self and the element
signs of sign.
Equivalent to (self.x.copysign(sign.x), self.y.copysign(sign.y), ...).
§Examples
let vector = Vec3::new(7.0, -1.0, -3.0);
let sign = Vec3::new(-5.0, -2.0, 1.0);
let copysign = vector.copysign(sign);
assert_eq!(copysign, Vec3::new(-7.0, -1.0, 3.0));Sourcepub fn floor(self) -> Self
pub fn floor(self) -> Self
Returns the largest integers less than or equal to the elements of
self.
This always returns the precise result.
§Examples
let vector = Vec3::new(3.7, 3.0, -3.7);
assert_eq!(vector.floor(), Vec3::new(3.0, 3.0, -4.0));Sourcepub fn ceil(self) -> Self
pub fn ceil(self) -> Self
Returns the smallest integers greater than or equal to the elements of
self.
This always returns the precise result.
§Examples
let vector = Vec3::new(3.01, 4.0, -4.99);
assert_eq!(vector.ceil(), Vec3::new(4.0, 4.0, -4.0));Sourcepub fn round(self) -> Self
pub fn round(self) -> Self
Returns the nearest integers to the elements of self.
This always returns the precise result. If a value is half-way between two integers, round away from 0.0.
§Examples
let vector = Vec3::new(3.3, -3.3, 3.5);
assert_eq!(vector.round(), Vec3::new(3.0, -3.0, 4.0));Sourcepub fn trunc(self) -> Self
pub fn trunc(self) -> Self
Returns the integer part of the elements of self. This means that
non-integer numbers are always truncated towards zero.
This always returns the precise result.
§Examples
let vector = Vec3::new(3.7, 3.0, -3.7);
assert_eq!(vector.trunc(), Vec3::new(3.0, 3.0, -3.0));Sourcepub fn fract(self) -> Self
pub fn fract(self) -> Self
Returns the fractional part of self. Equivalent to
self - self.trunc().
This always returns the precise result.
§Examples
let vector = Vec2::new(3.25, -3.25);
assert_eq!(vector.fract(), Vec2::new(0.25, -0.25));Sourcepub fn mul_add(self, a: Self, b: Self) -> Self
pub fn mul_add(self, a: Self, b: Self) -> Self
Fused multiply-add. Computes (self * a) + b with only one rounding
error, yielding a more accurate result than an unfused multiply-add.
Using mul_add is slower than an unfused multiply-add on most target
architectures.
§Precision
The result of this operation is guaranteed to be the rounded
infinite-precision result. It is specified by IEEE 754 as
fusedMultiplyAdd and guaranteed not to change.
Sourcepub fn div_euclid(self, rhs: Self) -> Self
pub fn div_euclid(self, rhs: Self) -> Self
Calculates Euclidean division for the elements of self.
Equivalent to
(self.x.div_euclid(rhs.x), self.y.div_euclid(rhs.y), ...).
See f32::div_euclid.
§Precision
The result of this operation is guaranteed to be the rounded infinite-precision result.
Sourcepub fn rem_euclid(self, rhs: Self) -> Self
pub fn rem_euclid(self, rhs: Self) -> Self
Calculates Euclidean remainder for the elements of self.
Equivalent to
(self.x.rem_euclid(rhs.x), self.y.rem_euclid(rhs.y), ...).
See f32::rem_euclid.
§Precision
The result of this operation is guaranteed to be the rounded infinite-precision result.
Sourcepub fn powf(self, n: T) -> Self
pub fn powf(self, n: T) -> Self
Computes x^n for the elements of self.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn sqrt(self) -> Self
pub fn sqrt(self) -> Self
Returns the square root of the elements of self.
Equivalent to (self.x.sqrt(), self.y.sqrt(), ...).
§Precision
The result of this operation is guaranteed to be the rounded
infinite-precision result. It is specified by IEEE 754 as squareRoot
and guaranteed not to change.
§Examples
let vector = Vec3::<f32>::new(4.0, 16.0, -4.0);
assert_eq!(vector.sqrt().x, 2.0);
assert_eq!(vector.sqrt().y, 4.0);
assert!(vector.sqrt().z.is_nan());Sourcepub fn exp(self) -> Self
pub fn exp(self) -> Self
Computes the exponential function e^x for the elements of self.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn exp2(self) -> Self
pub fn exp2(self) -> Self
Computes 2^x for the elements of self.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn ln(self) -> Self
pub fn ln(self) -> Self
Computes the natural logarithm for the elements of self.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn log2(self) -> Self
pub fn log2(self) -> Self
Computes the base 2 logarithm for the elements of self.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
§Examples
let vector = Vec3::new(2.0, 4.0, 8.0);
assert_eq!(vector.log2(), Vec3::new(1.0, 2.0, 3.0));Sourcepub fn sin(self) -> Self
pub fn sin(self) -> Self
Computes the sine of the elements of self.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn cos(self) -> Self
pub fn cos(self) -> Self
Computes the cosine of the elements of self.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn tan(self) -> Self
pub fn tan(self) -> Self
Computes the tangent of the elements of self.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn asin(self) -> Self
pub fn asin(self) -> Self
Computes the arcsine of the elements of self.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn acos(self) -> Self
pub fn acos(self) -> Self
Computes the arccosine of the elements of self.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn atan(self) -> Self
pub fn atan(self) -> Self
Computes the arctangent of the elements of self.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn sin_cos(self) -> (Self, Self)
pub fn sin_cos(self) -> (Self, Self)
Simultaneously computes the sine and cosine of the elements of self.
Equivalent to (self.sin(), self.cos()), but may be more performant.
This might return a slightly different value.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn lerp(self, other: Self, t: T) -> Self
pub fn lerp(self, other: Self, t: T) -> Self
Computes the linear interpolation between self and other based on
the value t.
When t is 0.0, the result is self. When t is 1.0, the result
is rhs. When t is outside of the range 0.0..=1.0, the result is
linearly extrapolated.
Sourcepub fn midpoint(self, other: Self) -> Self
pub fn midpoint(self, other: Self) -> Self
Computes the middle point between self and other.
Equivalent to self.lerp(other, 0.5), but is cheaper to compute. This
may return a slightly different value.
Sourcepub fn move_towards(self, target: Self, max_delta: T) -> Self
pub fn move_towards(self, target: Self, max_delta: T) -> Self
Moves self towards other by at most max_delta.
When max_delta is 0.0, the result is self. When max_delta is
equal to or greater than self.distance(other), the result is other.
let vector = Vec3::new(2.0, 0.0, 0.0);
let target = Vec3::new(5.0, 0.0, 0.0);
let max_delta = 1.0;
let move_towards = vector.move_towards(target, max_delta);
assert_eq!(move_towards, Vec3::new(3.0, 0.0, 0.0));Sourcepub fn slerp(self, other: Self, t: T) -> Self
pub fn slerp(self, other: Self, t: T) -> Self
Computes the spherical linear interpolation between self and other
based on the value t.
When t is 0, the result is self. When t is 1, the result
is other. When t is outside of the range 0..=1, the result is
spherically linearly extrapolated.
The vectors do not need to be unit vectors but they do need to be non-zero.
§Panics
When debug assertions are enabled:
Panics if self or other are zero vectors.
Sourcepub fn rotate_towards(self, target: Self, max_angle: T) -> Self
pub fn rotate_towards(self, target: Self, max_angle: T) -> Self
Rotates self towards target by at most max_angle (in radians).
When max_angle is 0, the result is self. When max_angle is equal
to or greater than self.angle_between(target), the result is target.
When max_angle is negative, this rotates towards -target.
The vectors do not need to be unit vectors but target does need to be
non-zero.
§Panics
When debug assertions are enabled:
Panics if target is a zero vector.
Sourcepub fn length(self) -> T
pub fn length(self) -> T
Returns the length/magnitude of self.
§Examples
let vector = Vec3::new(2.0, 3.0, 1.0);
assert_eq!(vector.length(), 14.0_f32.sqrt());Sourcepub fn distance(self, other: Self) -> T
pub fn distance(self, other: Self) -> T
Computes the Euclidean distance between self and other.
§Examples
let a = Vec3::new(1.0, 2.0, 3.0);
let b = Vec3::new(4.0, 5.0, 6.0);
assert_eq!(a.distance(b), (a - b).length());Sourcepub fn try_normalize(self) -> Option<Self>
pub fn try_normalize(self) -> Option<Self>
Sourcepub fn normalize_or(self, fallback: Self) -> Self
pub fn normalize_or(self, fallback: Self) -> Self
Returns normalize, or fallback if self is zero or if the result
is non finite or zero.
§Examples
let non_zero = Vec3::new(1.0, 2.0, 3.0);
let zero = Vec3::new(0.0, 0.0, 0.0);
let fallback = Vec3::new(9.0, 10.0, 21.0);
assert_eq!(non_zero.normalize_or(fallback), non_zero.normalize());
assert_eq!(zero.normalize_or(fallback), fallback);Sourcepub fn normalize_or_zero(self) -> Self
pub fn normalize_or_zero(self) -> Self
Sourcepub fn normalize_and_length(self) -> (Self, T)
pub fn normalize_and_length(self) -> (Self, T)
Simultaneously computes normalize and length.
If self is a zero vector, the result is length 0 and an unspecified
vector. Consider manually checking for length == 0.0.
§Examples
let vector = Vec3::new(1.0, 2.0, 3.0);
let (normalize, length) = vector.normalize_and_length();
assert_eq!(normalize, vector.normalize());
assert_eq!(length, vector.length());Sourcepub fn is_normalized(self) -> bool
pub fn is_normalized(self) -> bool
Returns whether the vector has the length 1.0 or not.
This uses a precision threshold of approximately 1e-4.
§Examples
let unit = Vec3::splat((1.0_f32 / 3.0).sqrt());
let non_unit = Vec3::splat(2.0);
assert!(unit.is_normalized());
assert!(!non_unit.is_normalized());Sourcepub fn with_max_length(self, max: T) -> Self
pub fn with_max_length(self, max: T) -> Self
Returns self with a length of no more than max.
§Panics
When debug assertions are enabled:
Panics if max is negative or self cannot be normalized.
§Examples
let a = Vec3::new(2.0, 0.0, 0.0);
let b = Vec3::new(6.0, 0.0, 0.0);
let max = 4.0;
assert_eq!(a.with_max_length(max), Vec3::new(2.0, 0.0, 0.0));
assert_eq!(b.with_max_length(max), Vec3::new(4.0, 0.0, 0.0));Sourcepub fn with_min_length(self, min: T) -> Self
pub fn with_min_length(self, min: T) -> Self
Returns self with a length of no less than min.
If min is negative, this returns self.
§Panics
When debug assertions are enabled:
Panics if self cannot be normalized.
§Examples
let a = Vec3::new(2.0, 0.0, 0.0);
let b = Vec3::new(6.0, 0.0, 0.0);
let min = 4.0;
assert_eq!(a.with_min_length(min), Vec3::new(4.0, 0.0, 0.0));
assert_eq!(b.with_min_length(min), Vec3::new(6.0, 0.0, 0.0));Sourcepub fn clamp_length(self, min: T, max: T) -> Self
pub fn clamp_length(self, min: T, max: T) -> Self
Returns self with a length of no less than min and no more than
max.
If min is negative it is ignored.
§Panics
When debug assertions are enabled:
Panics if min > max, max is negative or self cannot be normalized.
§Examples
let a = Vec3::new(2.0, 0.0, 0.0);
let b = Vec3::new(6.0, 0.0, 0.0);
let c = Vec3::new(10.0, 0.0, 0.0);
let min = 4.0;
let max = 8.0;
assert_eq!(a.clamp_length(min, max), Vec3::new(4.0, 0.0, 0.0));
assert_eq!(b.clamp_length(min, max), Vec3::new(6.0, 0.0, 0.0));
assert_eq!(c.clamp_length(min, max), Vec3::new(8.0, 0.0, 0.0));Sourcepub fn angle_between(self, other: Self) -> T
pub fn angle_between(self, other: Self) -> T
Returns the angle (in radians) between self and other in the range
0..=+π.
The vectors do not need to be unit vectors but they do need to be non-zero.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
§Panics
When debug assertions are enabled:
Panics if self or other are zero vectors.
§Examples
let x = Vec3::new(2.0, 0.0, 0.0);
let y = Vec3::new(0.0, 3.0, 0.0);
let angle = x.angle_between(y);
assert!((angle - 90.0_f32.to_radians()).abs() < 1e-5);Sourcepub fn project_onto(self, other: Self) -> Self
pub fn project_onto(self, other: Self) -> Self
Returns the vector projection of self onto other.
other must not be a zero vector.
§Panics
When debug assertions are enabled:
Panics if other is a zero vector.
Sourcepub fn project_onto_normalized(self, other: Self) -> Self
pub fn project_onto_normalized(self, other: Self) -> Self
Returns the vector projection of self onto other.
other must be normalized.
§Panics
When debug assertions are enabled:
Panics if other is not normalized.
Sourcepub fn reject_from(self, other: Self) -> Self
pub fn reject_from(self, other: Self) -> Self
Returns the vector rejection of self from other.
Equivalent to self - self.project_onto(other).
other must not be a zero vector.
§Panics
When debug assertions are enabled:
Panics if other is a zero vector.
Sourcepub fn reject_from_normalized(self, other: Self) -> Self
pub fn reject_from_normalized(self, other: Self) -> Self
Returns the vector rejection of self from other.
Equivalent to self - self.project_onto(other).
other must be normalized.
§Panics
When debug assertions are enabled:
Panics if other is not normalized.
Sourcepub fn reflect(self, normal: Self) -> Self
pub fn reflect(self, normal: Self) -> Self
Returns the reflection of self through normal.
normal must be normalized.
§Panics
When debug assertions are enabled:
Panics if normal is not normalized.
Sourcepub fn refract(self, normal: Self, eta: T) -> Self
pub fn refract(self, normal: Self, eta: T) -> Self
Returns the vector refraction of self through normal and eta.
eta is the incident refraction-index divided by the transmitted
refraction-index.
When total internal reflection occurs, the result is a zero vector.
self and normal must be normalized.
§Panics
When debug assertions are enabled:
Panics if self or normal are not normalized.
Sourcepub fn any_orthogonal_vector(self) -> Self
pub fn any_orthogonal_vector(self) -> Self
Returns some vector that is orthogonal to self.
The result is not necessarily normalized. For that use
any_orthonormal_vector instead.
For 2D vectors this is equivalent to perp.
Sourcepub fn any_orthonormal_vector(self) -> Self
pub fn any_orthonormal_vector(self) -> Self
Sourcepub fn abs_diff_eq(self, other: Self, max_abs_diff: T) -> bool
pub fn abs_diff_eq(self, other: Self, max_abs_diff: T) -> bool
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 two vectors that should be equal, but may have a slight difference due to operations having rounding errors.
Source§impl<T, A: Alignment> Vector<2, T, A>where
T: PrimitiveFloat,
impl<T, A: Alignment> Vector<2, T, A>where
T: PrimitiveFloat,
Sourcepub fn angle_to(self, other: Self) -> T
pub fn angle_to(self, other: Self) -> T
Returns the angle (in radians) that rotates self to other in the
range -π..=+π.
The vectors do not need to be unit vectors but they do need to be non-zero.
Equivalent to other.angle_from(self).
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
§Panics
When debug assertions are enabled:
Panics if self or other are zero vectors.
§Examples
let x = Vec2::new(2.0, 0.0);
let y = Vec2::new(0.0, 3.0);
assert!(x.angle_to(y) > 0.0);
assert!(y.angle_to(x) < 0.0);Sourcepub fn angle_from(self, other: Self) -> T
pub fn angle_from(self, other: Self) -> T
Returns the angle (in radians) that rotates other to self in the
range -π..=+π.
The vectors do not need to be unit vectors but they do need to be non-zero.
Equivalent to other.angle_to(self).
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
§Panics
When debug assertions are enabled:
Panics if self or other are zero vectors.
§Examples
let x = Vec2::new(2.0, 0.0);
let y = Vec2::new(0.0, 3.0);
assert!(x.angle_from(y) < 0.0);
assert!(y.angle_from(x) > 0.0);Source§impl<T, A: Alignment> Vector<3, T, A>where
T: PrimitiveFloat,
impl<T, A: Alignment> Vector<3, T, A>where
T: PrimitiveFloat,
Sourcepub fn from_homogeneous(homogeneous: Vector<4, T, A>) -> Self
pub fn from_homogeneous(homogeneous: Vector<4, T, A>) -> Self
Creates a 3D vector from homogeneous coordinates by performing perspective divide.
Equivalent to homogeneous.xyz / homogeneous.w.
Sourcepub fn rotate_x(self, angle: T) -> Self
pub fn rotate_x(self, angle: T) -> Self
Rotates self around the x axis by angle (in radians).
This rotates +Y to +Z.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn rotate_y(self, angle: T) -> Self
pub fn rotate_y(self, angle: T) -> Self
Rotates self around the y axis by angle (in radians).
This rotates +Z to +X.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn rotate_z(self, angle: T) -> Self
pub fn rotate_z(self, angle: T) -> Self
Rotates self around the z axis by angle (in radians).
This rotates +X to +Y.
§Unspecified precision
The precision of this function is non-deterministic. This means it varies by platform, version, and can even differ within the same execution from one invocation to the next.
Sourcepub fn any_orthonormal_pair(self) -> (Self, Self)
pub fn any_orthonormal_pair(self) -> (Self, Self)
Returns two unit vectors that are orthogonal to self and to each
other.
Together with self, they form an orthonormal basis where the three
vectors are all orthogonal to each other and are normalized.
§Panics
When debug assertions are enabled:
Panics if self is not normalized.
Source§impl<const N: usize, T, A: Alignment> Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Vector<N, T, A>
Sourcepub fn checked_add(self, rhs: Self) -> Option<Self>
pub fn checked_add(self, rhs: Self) -> Option<Self>
Computes self + rhs, returning None if overflow occured.
Sourcepub fn checked_sub(self, rhs: Self) -> Option<Self>
pub fn checked_sub(self, rhs: Self) -> Option<Self>
Computes self - rhs, returning None if overflow occured.
Sourcepub fn checked_mul(self, rhs: Self) -> Option<Self>
pub fn checked_mul(self, rhs: Self) -> Option<Self>
Computes self * rhs, returning None if overflow occured.
Sourcepub fn checked_div(self, rhs: Self) -> Option<Self>
pub fn checked_div(self, rhs: Self) -> Option<Self>
Computes self / rhs, returning None if overflow or division
by zero occured.
Sourcepub fn checked_rem(self, rhs: Self) -> Option<Self>
pub fn checked_rem(self, rhs: Self) -> Option<Self>
Computes self % rhs, returning None if overflow or division
by zero occurred.
Sourcepub fn saturating_add(self, rhs: Self) -> Self
pub fn saturating_add(self, rhs: Self) -> Self
Computes self + rhs, saturating at the numeric bounds instead of
overflowing.
Sourcepub fn saturating_sub(self, rhs: Self) -> Self
pub fn saturating_sub(self, rhs: Self) -> Self
Computes self - rhs, saturating at the numeric bounds instead of
overflowing.
Sourcepub fn saturating_mul(self, rhs: Self) -> Self
pub fn saturating_mul(self, rhs: Self) -> Self
Computes self * rhs, saturating at the numeric bounds instead of
overflowing.
Sourcepub fn saturating_div(self, rhs: Self) -> Self
pub fn saturating_div(self, rhs: Self) -> Self
Computes self / rhs, saturating at the numeric bounds instead of
overflowing.
§Panics
Panics if any component of rhs is 0.
Sourcepub fn wrapping_add(self, rhs: Self) -> Self
pub fn wrapping_add(self, rhs: Self) -> Self
Computes self + rhs, wrapping around at the boundary of the type.
Sourcepub fn wrapping_sub(self, rhs: Self) -> Self
pub fn wrapping_sub(self, rhs: Self) -> Self
Computes self - rhs, wrapping around at the boundary of the type.
Sourcepub fn wrapping_mul(self, rhs: Self) -> Self
pub fn wrapping_mul(self, rhs: Self) -> Self
Computes self * rhs, wrapping around at the boundary of the type.
Sourcepub fn wrapping_div(self, rhs: Self) -> Self
pub fn wrapping_div(self, rhs: Self) -> Self
Computes self / rhs, wrapping around at the boundary of the type.
§Panics
Panics if any component of rhs is 0.
Sourcepub fn wrapping_rem(self, rhs: Self) -> Self
pub fn wrapping_rem(self, rhs: Self) -> Self
Computes self % rhs, wrapping around at the boundary of the type.
§Panics
Panics if any component of rhs is 0.
Source§impl<const N: usize, A: Alignment> Vector<N, i8, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, i8, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> i8
pub fn max_element(self) -> i8
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> i8
pub fn min_element(self) -> i8
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, A: Alignment> Vector<N, i16, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, i16, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> i16
pub fn max_element(self) -> i16
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> i16
pub fn min_element(self) -> i16
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, A: Alignment> Vector<N, i32, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, i32, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> i32
pub fn max_element(self) -> i32
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> i32
pub fn min_element(self) -> i32
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, A: Alignment> Vector<N, i64, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, i64, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> i64
pub fn max_element(self) -> i64
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> i64
pub fn min_element(self) -> i64
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, A: Alignment> Vector<N, i128, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, i128, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> i128
pub fn max_element(self) -> i128
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> i128
pub fn min_element(self) -> i128
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, A: Alignment> Vector<N, isize, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, isize, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> isize
pub fn max_element(self) -> isize
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> isize
pub fn min_element(self) -> isize
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, A: Alignment> Vector<N, u8, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, u8, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> u8
pub fn max_element(self) -> u8
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> u8
pub fn min_element(self) -> u8
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, A: Alignment> Vector<N, u16, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, u16, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> u16
pub fn max_element(self) -> u16
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> u16
pub fn min_element(self) -> u16
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, A: Alignment> Vector<N, u32, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, u32, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> u32
pub fn max_element(self) -> u32
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> u32
pub fn min_element(self) -> u32
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, A: Alignment> Vector<N, u64, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, u64, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> u64
pub fn max_element(self) -> u64
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> u64
pub fn min_element(self) -> u64
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, A: Alignment> Vector<N, u128, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, u128, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> u128
pub fn max_element(self) -> u128
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> u128
pub fn min_element(self) -> u128
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, A: Alignment> Vector<N, usize, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, usize, A>where
Length<N>: SupportedLength,
Sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Returns the maximum elements between self and other.
Equivalent to (self.x.max(other.x), self.y.max(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let max = a.max(b);
assert_eq!(max, Vec4::new(3, 5, 7, 0));Sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Returns the minimum elements between self and other.
Equivalent to (self.x.min(other.x), self.y.min(other.y), ...).
§Examples
let a = Vec4::<i32>::new(1, 5, 3, 0);
let b = Vec4::<i32>::new(3, 2, 7, -1);
let min = a.min(b);
assert_eq!(min, Vec4::new(1, 2, 3, -1));Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Clamps the elements of self between the elements of min and
max.
Equivalent to
(self.x.clamp(min.x, max.x), self.y.clamp(min.y, max.y), ...).
§Panics
When debug assertions are enabled:
Panics if any element of min is greater than the corresponding
element of max.
§Examples
let vector = Vec4::<i32>::new(1, 2, 3, 0);
let min = Vec4::new(0, 5, 1, -2);
let max = Vec4::new(3, 6, 2, -1);
let clamp = vector.clamp(min, max);
assert_eq!(clamp, Vec4::new(1, 5, 2, -1));Sourcepub fn max_element(self) -> usize
pub fn max_element(self) -> usize
Returns the maximum between the elements of self.
Equivalent to self.x.max(self.y).max(self.z)....
§Examples
let vector = Vec3::<i32>::new(-1, 7, 3);
assert_eq!(vector.max_element(), 7);Sourcepub fn min_element(self) -> usize
pub fn min_element(self) -> usize
Returns the minimum between the elements of self.
Equivalent to self.x.min(self.y).min(self.z)....
§Examples
let vector = Vec3::<i32>::new(7, -1, 3);
assert_eq!(vector.min_element(), -1);Source§impl<const N: usize, T, A: Alignment> Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Vector<N, T, A>
Sourcepub fn positive_mask(self) -> Mask<N, T, A>
pub fn positive_mask(self) -> Mask<N, T, A>
Returns a vector mask where each element is true if the corresponding
element of self is positive, and false if it is zero or negative.
Equivalent to (self.x.is_positive(), self.y.is_positive(), ...).
§Examples
let vector = Vec4::new(1, -2, -3, 4);
let mask = vector.positive_mask();
assert_eq!(mask, Mask4::new(true, false, false, true));Sourcepub fn negative_mask(self) -> Mask<N, T, A>
pub fn negative_mask(self) -> Mask<N, T, A>
Returns a vector mask where each element is true if the corresponding
element of self is negative, and false if it is zero or positive.
Equivalent to (self.x.is_negative(), self.y.is_negative(), ...).
§Examples
let vector = Vec4::new(1, -2, -3, 4);
let mask = vector.negative_mask();
assert_eq!(mask, Mask4::new(false, true, true, false));Sourcepub const fn cast_unsigned(
self,
) -> Vector<N, <T as PrimitiveSigned>::Unsigned, A>
pub const fn cast_unsigned( self, ) -> Vector<N, <T as PrimitiveSigned>::Unsigned, A>
Returns the bit patterns of self reinterpreted as unsigned integers of
the same size.
This produces the same result as as conversions, but ensures that
the bit-width remains the same.
Source§impl<const N: usize, A: Alignment> Vector<N, i8, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, i8, A>where
Length<N>: SupportedLength,
Sourcepub fn signum(self) -> Self
pub fn signum(self) -> Self
Returns the signum of the elements of self.
Equivalent to (self.x.signum(), self.y.signum(), ...).
For each element:
0if the element is zero1if the element is positive-1if the element is negative
§Examples
let vector = Vec4::<i32>::new(7, -1, -3, 0);
assert_eq!(vector.signum(), Vec4::new(1, -1, -1, 0));Source§impl<const N: usize, A: Alignment> Vector<N, i16, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, i16, A>where
Length<N>: SupportedLength,
Sourcepub fn signum(self) -> Self
pub fn signum(self) -> Self
Returns the signum of the elements of self.
Equivalent to (self.x.signum(), self.y.signum(), ...).
For each element:
0if the element is zero1if the element is positive-1if the element is negative
§Examples
let vector = Vec4::<i32>::new(7, -1, -3, 0);
assert_eq!(vector.signum(), Vec4::new(1, -1, -1, 0));Source§impl<const N: usize, A: Alignment> Vector<N, i32, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, i32, A>where
Length<N>: SupportedLength,
Sourcepub fn signum(self) -> Self
pub fn signum(self) -> Self
Returns the signum of the elements of self.
Equivalent to (self.x.signum(), self.y.signum(), ...).
For each element:
0if the element is zero1if the element is positive-1if the element is negative
§Examples
let vector = Vec4::<i32>::new(7, -1, -3, 0);
assert_eq!(vector.signum(), Vec4::new(1, -1, -1, 0));Source§impl<const N: usize, A: Alignment> Vector<N, i64, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, i64, A>where
Length<N>: SupportedLength,
Sourcepub fn signum(self) -> Self
pub fn signum(self) -> Self
Returns the signum of the elements of self.
Equivalent to (self.x.signum(), self.y.signum(), ...).
For each element:
0if the element is zero1if the element is positive-1if the element is negative
§Examples
let vector = Vec4::<i32>::new(7, -1, -3, 0);
assert_eq!(vector.signum(), Vec4::new(1, -1, -1, 0));Source§impl<const N: usize, A: Alignment> Vector<N, i128, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, i128, A>where
Length<N>: SupportedLength,
Sourcepub fn signum(self) -> Self
pub fn signum(self) -> Self
Returns the signum of the elements of self.
Equivalent to (self.x.signum(), self.y.signum(), ...).
For each element:
0if the element is zero1if the element is positive-1if the element is negative
§Examples
let vector = Vec4::<i32>::new(7, -1, -3, 0);
assert_eq!(vector.signum(), Vec4::new(1, -1, -1, 0));Source§impl<const N: usize, A: Alignment> Vector<N, isize, A>where
Length<N>: SupportedLength,
impl<const N: usize, A: Alignment> Vector<N, isize, A>where
Length<N>: SupportedLength,
Sourcepub fn signum(self) -> Self
pub fn signum(self) -> Self
Returns the signum of the elements of self.
Equivalent to (self.x.signum(), self.y.signum(), ...).
For each element:
0if the element is zero1if the element is positive-1if the element is negative
§Examples
let vector = Vec4::<i32>::new(7, -1, -3, 0);
assert_eq!(vector.signum(), Vec4::new(1, -1, -1, 0));Source§impl<T, A: Alignment> Vector<2, T, A>where
T: Scalar,
impl<T, A: Alignment> Vector<2, T, A>where
T: Scalar,
Source§impl<T, A: Alignment> Vector<3, T, A>where
T: Scalar,
impl<T, A: Alignment> Vector<3, T, A>where
T: Scalar,
Sourcepub fn with_xy(self, value: Vector<2, T, A>) -> Self
pub fn with_xy(self, value: Vector<2, T, A>) -> Self
Returns self with the elements x and y replaced by value.x and value.y.
Sourcepub fn with_xz(self, value: Vector<2, T, A>) -> Self
pub fn with_xz(self, value: Vector<2, T, A>) -> Self
Returns self with the elements x and z replaced by value.x and value.y.
Sourcepub fn with_yx(self, value: Vector<2, T, A>) -> Self
pub fn with_yx(self, value: Vector<2, T, A>) -> Self
Returns self with the elements y and x replaced by value.x and value.y.
Sourcepub fn with_yz(self, value: Vector<2, T, A>) -> Self
pub fn with_yz(self, value: Vector<2, T, A>) -> Self
Returns self with the elements y and z replaced by value.x and value.y.
Sourcepub fn with_zx(self, value: Vector<2, T, A>) -> Self
pub fn with_zx(self, value: Vector<2, T, A>) -> Self
Returns self with the elements z and x replaced by value.x and value.y.
Sourcepub fn with_zy(self, value: Vector<2, T, A>) -> Self
pub fn with_zy(self, value: Vector<2, T, A>) -> Self
Returns self with the elements z and y replaced by value.x and value.y.
Sourcepub fn with_xzy(self, value: Vector<3, T, A>) -> Self
pub fn with_xzy(self, value: Vector<3, T, A>) -> Self
Returns self with the elements x, z and y replaced by value.x, value.y and value.z.
Sourcepub fn with_yxz(self, value: Vector<3, T, A>) -> Self
pub fn with_yxz(self, value: Vector<3, T, A>) -> Self
Returns self with the elements y, x and z replaced by value.x, value.y and value.z.
Sourcepub fn with_yzx(self, value: Vector<3, T, A>) -> Self
pub fn with_yzx(self, value: Vector<3, T, A>) -> Self
Returns self with the elements y, z and x replaced by value.x, value.y and value.z.
Sourcepub fn with_zxy(self, value: Vector<3, T, A>) -> Self
pub fn with_zxy(self, value: Vector<3, T, A>) -> Self
Returns self with the elements z, x and y replaced by value.x, value.y and value.z.
Source§impl<T, A: Alignment> Vector<4, T, A>where
T: Scalar,
impl<T, A: Alignment> Vector<4, T, A>where
T: Scalar,
Sourcepub fn with_xy(self, value: Vector<2, T, A>) -> Self
pub fn with_xy(self, value: Vector<2, T, A>) -> Self
Returns self with the elements x and y replaced by value.x and value.y.
Sourcepub fn with_xz(self, value: Vector<2, T, A>) -> Self
pub fn with_xz(self, value: Vector<2, T, A>) -> Self
Returns self with the elements x and z replaced by value.x and value.y.
Sourcepub fn with_xw(self, value: Vector<2, T, A>) -> Self
pub fn with_xw(self, value: Vector<2, T, A>) -> Self
Returns self with the elements x and w replaced by value.x and value.y.
Sourcepub fn with_yx(self, value: Vector<2, T, A>) -> Self
pub fn with_yx(self, value: Vector<2, T, A>) -> Self
Returns self with the elements y and x replaced by value.x and value.y.
Sourcepub fn with_yz(self, value: Vector<2, T, A>) -> Self
pub fn with_yz(self, value: Vector<2, T, A>) -> Self
Returns self with the elements y and z replaced by value.x and value.y.
Sourcepub fn with_yw(self, value: Vector<2, T, A>) -> Self
pub fn with_yw(self, value: Vector<2, T, A>) -> Self
Returns self with the elements y and w replaced by value.x and value.y.
Sourcepub fn with_zx(self, value: Vector<2, T, A>) -> Self
pub fn with_zx(self, value: Vector<2, T, A>) -> Self
Returns self with the elements z and x replaced by value.x and value.y.
Sourcepub fn with_zy(self, value: Vector<2, T, A>) -> Self
pub fn with_zy(self, value: Vector<2, T, A>) -> Self
Returns self with the elements z and y replaced by value.x and value.y.
Sourcepub fn with_zw(self, value: Vector<2, T, A>) -> Self
pub fn with_zw(self, value: Vector<2, T, A>) -> Self
Returns self with the elements z and w replaced by value.x and value.y.
Sourcepub fn with_wx(self, value: Vector<2, T, A>) -> Self
pub fn with_wx(self, value: Vector<2, T, A>) -> Self
Returns self with the elements w and x replaced by value.x and value.y.
Sourcepub fn with_wy(self, value: Vector<2, T, A>) -> Self
pub fn with_wy(self, value: Vector<2, T, A>) -> Self
Returns self with the elements w and y replaced by value.x and value.y.
Sourcepub fn with_wz(self, value: Vector<2, T, A>) -> Self
pub fn with_wz(self, value: Vector<2, T, A>) -> Self
Returns self with the elements w and z replaced by value.x and value.y.
Sourcepub fn with_xyz(self, value: Vector<3, T, A>) -> Self
pub fn with_xyz(self, value: Vector<3, T, A>) -> Self
Returns self with the elements x, y and z replaced by value.x, value.y and value.z.
Sourcepub fn with_xyw(self, value: Vector<3, T, A>) -> Self
pub fn with_xyw(self, value: Vector<3, T, A>) -> Self
Returns self with the elements x, y and w replaced by value.x, value.y and value.z.
Sourcepub fn with_xzy(self, value: Vector<3, T, A>) -> Self
pub fn with_xzy(self, value: Vector<3, T, A>) -> Self
Returns self with the elements x, z and y replaced by value.x, value.y and value.z.
Sourcepub fn with_xzw(self, value: Vector<3, T, A>) -> Self
pub fn with_xzw(self, value: Vector<3, T, A>) -> Self
Returns self with the elements x, z and w replaced by value.x, value.y and value.z.
Sourcepub fn with_xwy(self, value: Vector<3, T, A>) -> Self
pub fn with_xwy(self, value: Vector<3, T, A>) -> Self
Returns self with the elements x, w and y replaced by value.x, value.y and value.z.
Sourcepub fn with_xwz(self, value: Vector<3, T, A>) -> Self
pub fn with_xwz(self, value: Vector<3, T, A>) -> Self
Returns self with the elements x, w and z replaced by value.x, value.y and value.z.
Sourcepub fn with_yxz(self, value: Vector<3, T, A>) -> Self
pub fn with_yxz(self, value: Vector<3, T, A>) -> Self
Returns self with the elements y, x and z replaced by value.x, value.y and value.z.
Sourcepub fn with_yxw(self, value: Vector<3, T, A>) -> Self
pub fn with_yxw(self, value: Vector<3, T, A>) -> Self
Returns self with the elements y, x and w replaced by value.x, value.y and value.z.
Sourcepub fn with_yzx(self, value: Vector<3, T, A>) -> Self
pub fn with_yzx(self, value: Vector<3, T, A>) -> Self
Returns self with the elements y, z and x replaced by value.x, value.y and value.z.
Sourcepub fn with_yzw(self, value: Vector<3, T, A>) -> Self
pub fn with_yzw(self, value: Vector<3, T, A>) -> Self
Returns self with the elements y, z and w replaced by value.x, value.y and value.z.
Sourcepub fn with_ywx(self, value: Vector<3, T, A>) -> Self
pub fn with_ywx(self, value: Vector<3, T, A>) -> Self
Returns self with the elements y, w and x replaced by value.x, value.y and value.z.
Sourcepub fn with_ywz(self, value: Vector<3, T, A>) -> Self
pub fn with_ywz(self, value: Vector<3, T, A>) -> Self
Returns self with the elements y, w and z replaced by value.x, value.y and value.z.
Sourcepub fn with_zxy(self, value: Vector<3, T, A>) -> Self
pub fn with_zxy(self, value: Vector<3, T, A>) -> Self
Returns self with the elements z, x and y replaced by value.x, value.y and value.z.
Sourcepub fn with_zxw(self, value: Vector<3, T, A>) -> Self
pub fn with_zxw(self, value: Vector<3, T, A>) -> Self
Returns self with the elements z, x and w replaced by value.x, value.y and value.z.
Sourcepub fn with_zyx(self, value: Vector<3, T, A>) -> Self
pub fn with_zyx(self, value: Vector<3, T, A>) -> Self
Returns self with the elements z, y and x replaced by value.x, value.y and value.z.
Sourcepub fn with_zyw(self, value: Vector<3, T, A>) -> Self
pub fn with_zyw(self, value: Vector<3, T, A>) -> Self
Returns self with the elements z, y and w replaced by value.x, value.y and value.z.
Sourcepub fn with_zwx(self, value: Vector<3, T, A>) -> Self
pub fn with_zwx(self, value: Vector<3, T, A>) -> Self
Returns self with the elements z, w and x replaced by value.x, value.y and value.z.
Sourcepub fn with_zwy(self, value: Vector<3, T, A>) -> Self
pub fn with_zwy(self, value: Vector<3, T, A>) -> Self
Returns self with the elements z, w and y replaced by value.x, value.y and value.z.
Sourcepub fn with_wxy(self, value: Vector<3, T, A>) -> Self
pub fn with_wxy(self, value: Vector<3, T, A>) -> Self
Returns self with the elements w, x and y replaced by value.x, value.y and value.z.
Sourcepub fn with_wxz(self, value: Vector<3, T, A>) -> Self
pub fn with_wxz(self, value: Vector<3, T, A>) -> Self
Returns self with the elements w, x and z replaced by value.x, value.y and value.z.
Sourcepub fn with_wyx(self, value: Vector<3, T, A>) -> Self
pub fn with_wyx(self, value: Vector<3, T, A>) -> Self
Returns self with the elements w, y and x replaced by value.x, value.y and value.z.
Sourcepub fn with_wyz(self, value: Vector<3, T, A>) -> Self
pub fn with_wyz(self, value: Vector<3, T, A>) -> Self
Returns self with the elements w, y and z replaced by value.x, value.y and value.z.
Sourcepub fn with_wzx(self, value: Vector<3, T, A>) -> Self
pub fn with_wzx(self, value: Vector<3, T, A>) -> Self
Returns self with the elements w, z and x replaced by value.x, value.y and value.z.
Sourcepub fn with_wzy(self, value: Vector<3, T, A>) -> Self
pub fn with_wzy(self, value: Vector<3, T, A>) -> Self
Returns self with the elements w, z and y replaced by value.x, value.y and value.z.
Sourcepub fn with_xywz(self, value: Vector<4, T, A>) -> Self
pub fn with_xywz(self, value: Vector<4, T, A>) -> Self
Returns self with the elements x, y, w and z replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_xzyw(self, value: Vector<4, T, A>) -> Self
pub fn with_xzyw(self, value: Vector<4, T, A>) -> Self
Returns self with the elements x, z, y and w replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_xzwy(self, value: Vector<4, T, A>) -> Self
pub fn with_xzwy(self, value: Vector<4, T, A>) -> Self
Returns self with the elements x, z, w and y replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_xwyz(self, value: Vector<4, T, A>) -> Self
pub fn with_xwyz(self, value: Vector<4, T, A>) -> Self
Returns self with the elements x, w, y and z replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_xwzy(self, value: Vector<4, T, A>) -> Self
pub fn with_xwzy(self, value: Vector<4, T, A>) -> Self
Returns self with the elements x, w, z and y replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_yxzw(self, value: Vector<4, T, A>) -> Self
pub fn with_yxzw(self, value: Vector<4, T, A>) -> Self
Returns self with the elements y, x, z and w replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_yxwz(self, value: Vector<4, T, A>) -> Self
pub fn with_yxwz(self, value: Vector<4, T, A>) -> Self
Returns self with the elements y, x, w and z replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_yzxw(self, value: Vector<4, T, A>) -> Self
pub fn with_yzxw(self, value: Vector<4, T, A>) -> Self
Returns self with the elements y, z, x and w replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_yzwx(self, value: Vector<4, T, A>) -> Self
pub fn with_yzwx(self, value: Vector<4, T, A>) -> Self
Returns self with the elements y, z, w and x replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_ywxz(self, value: Vector<4, T, A>) -> Self
pub fn with_ywxz(self, value: Vector<4, T, A>) -> Self
Returns self with the elements y, w, x and z replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_ywzx(self, value: Vector<4, T, A>) -> Self
pub fn with_ywzx(self, value: Vector<4, T, A>) -> Self
Returns self with the elements y, w, z and x replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_zxyw(self, value: Vector<4, T, A>) -> Self
pub fn with_zxyw(self, value: Vector<4, T, A>) -> Self
Returns self with the elements z, x, y and w replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_zxwy(self, value: Vector<4, T, A>) -> Self
pub fn with_zxwy(self, value: Vector<4, T, A>) -> Self
Returns self with the elements z, x, w and y replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_zyxw(self, value: Vector<4, T, A>) -> Self
pub fn with_zyxw(self, value: Vector<4, T, A>) -> Self
Returns self with the elements z, y, x and w replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_zywx(self, value: Vector<4, T, A>) -> Self
pub fn with_zywx(self, value: Vector<4, T, A>) -> Self
Returns self with the elements z, y, w and x replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_zwxy(self, value: Vector<4, T, A>) -> Self
pub fn with_zwxy(self, value: Vector<4, T, A>) -> Self
Returns self with the elements z, w, x and y replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_zwyx(self, value: Vector<4, T, A>) -> Self
pub fn with_zwyx(self, value: Vector<4, T, A>) -> Self
Returns self with the elements z, w, y and x replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_wxyz(self, value: Vector<4, T, A>) -> Self
pub fn with_wxyz(self, value: Vector<4, T, A>) -> Self
Returns self with the elements w, x, y and z replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_wxzy(self, value: Vector<4, T, A>) -> Self
pub fn with_wxzy(self, value: Vector<4, T, A>) -> Self
Returns self with the elements w, x, z and y replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_wyxz(self, value: Vector<4, T, A>) -> Self
pub fn with_wyxz(self, value: Vector<4, T, A>) -> Self
Returns self with the elements w, y, x and z replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_wyzx(self, value: Vector<4, T, A>) -> Self
pub fn with_wyzx(self, value: Vector<4, T, A>) -> Self
Returns self with the elements w, y, z and x replaced by value.x, value.y, value.z and value.w.
Sourcepub fn with_wzxy(self, value: Vector<4, T, A>) -> Self
pub fn with_wzxy(self, value: Vector<4, T, A>) -> Self
Returns self with the elements w, z, x and y replaced by value.x, value.y, value.z and value.w.
Source§impl<const N: usize, T, A: Alignment> Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Vector<N, T, A>
Sourcepub const fn cast_signed(self) -> Vector<N, <T as PrimitiveUnsigned>::Signed, A>
pub const fn cast_signed(self) -> Vector<N, <T as PrimitiveUnsigned>::Signed, A>
Returns the bit patterns of self reinterpreted as signed integers of
the same size.
This produces the same result as as conversions, but ensures that
the bit-width remains the same.
Source§impl<const N: usize, T, A: Alignment> Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Vector<N, T, A>
Sourcepub const fn from_array(array: [T; N]) -> Self
pub const fn from_array(array: [T; N]) -> Self
Creates a vector from an array.
Sourcepub const fn splat(value: T) -> Self
pub const fn splat(value: T) -> Self
Creates a vector with all elements set to value.
§Examples
let vector = Vec3::splat(5);
assert_eq!(vector, Vec3::new(5, 5, 5));Sourcepub fn from_fn<F>(f: F) -> Self
pub fn from_fn<F>(f: F) -> Self
Creates a vector by calling function f for each element index.
Equivalent to (f(0), f(1), f(2), ...).
§Examples
let indices = Vec3::from_fn(|i| i);
assert_eq!(indices, Vec3::new(0, 1, 2));
let vector = Vec3::from_fn(|i| i % 2);
assert_eq!(vector, Vec3::new(0, 1, 0));Sourcepub const fn to_alignment<A2: Alignment>(self) -> Vector<N, T, A2>
pub const fn to_alignment<A2: Alignment>(self) -> Vector<N, T, A2>
Conversion between Aligned and Unaligned storage.
See align and unalign for scenarios where the output alignment
is known.
See Alignment for more details.
§Examples
let unaligned = Vec3::new(1, 2, 3);
let aligned = unaligned.to_alignment::<Aligned>();
assert_eq!(aligned, Vec3A::new(1, 2, 3));
let aligned = Vec3A::new(1, 2, 3);
let unaligned = aligned.to_alignment::<Unaligned>();
assert_eq!(unaligned, Vec3::new(1, 2, 3));Sourcepub const fn as_mut_array(&mut self) -> &mut [T; N]
pub const fn as_mut_array(&mut self) -> &mut [T; N]
Returns a mutable reference to the vector’s elements.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Returns an iterator over mutable references to the vector’s elements.
Sourcepub fn map<U, F>(self, f: F) -> Vector<N, U, A>
pub fn map<U, F>(self, f: F) -> Vector<N, U, A>
Returns a vector of the same length as self, with function f applied
to each element in order.
Equivalent to (f(self.x), f(self.y), f(self.z), ..).
§Examples
let a = Vec3::new(1, 2, 3);
let b = a.map(|x| x + 1);
assert_eq!(b, Vec3::new(2, 3, 4));
let a = Vec3::<i32>::new(1, -2, -3);
let b = a.map(|x| x.is_negative());
assert_eq!(b, Vec3::new(false, true, true));Sourcepub fn reverse(self) -> Self
pub fn reverse(self) -> Self
Returns a vector with the elements of self in reverse order.
§Examples
let vector = Vec3::new(1, 2, 3).reverse();
assert_eq!(vector, Vec3::new(3, 2, 1));Sourcepub fn element_sum(self) -> Twhere
T: Add<Output = T>,
pub fn element_sum(self) -> Twhere
T: Add<Output = T>,
Sourcepub fn element_product(self) -> Twhere
T: Mul<Output = T>,
pub fn element_product(self) -> Twhere
T: Mul<Output = T>,
Computes the product of the elements of self.
Equivalent to self.x * self.y * ....
§Panics
When debug assertions or overflow checks are enabled:
For integers this panics if any multiplication overflows (order unspecified).
§Consistency
For primitive types this operation is cross platform deterministic.
Sourcepub fn eq_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialEq,
pub fn eq_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialEq,
Returns a vector mask where each element is true if the corresponding
elements of self and other are equal.
Equivalent to (self.x == other.x, self.y == other.y, ...).
§Examples
let vector = Vec3::new(1, 2, 3);
let mask = vector.eq_mask(Vec3::new(0, 2, 5));
assert_eq!(mask, Mask3::new(false, true, false));Sourcepub fn ne_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialEq,
pub fn ne_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialEq,
Returns a vector mask where each element is true if the corresponding
elements of self and other are not equal.
Equivalent to (self.x != other.x, self.y != other.y, ...).
§Examples
let vector = Vec3::new(1, 2, 3);
let mask = vector.ne_mask(Vec3::new(0, 2, 5));
assert_eq!(mask, Mask3::new(true, false, true));Sourcepub fn lt_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialOrd,
pub fn lt_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialOrd,
Returns a vector mask where each element is true if the corresponding
element of self is less than the corresponding element of other.
Equivalent to (self.x < other.x, self.y < other.y, ...).
§Examples
let vector = Vec3::new(1, 2, 3);
let mask = vector.lt_mask(Vec3::new(0, 2, 5));
assert_eq!(mask, Mask3::new(false, false, true));Sourcepub fn gt_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialOrd,
pub fn gt_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialOrd,
Returns a vector mask where each element is true if the corresponding
element of self is greater than the corresponding element of other.
Equivalent to (self.x > other.x, self.y > other.y, ...).
§Examples
let vector = Vec3::new(1, 2, 3);
let mask = vector.gt_mask(Vec3::new(0, 2, 5));
assert_eq!(mask, Mask3::new(true, false, false));Sourcepub fn le_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialOrd,
pub fn le_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialOrd,
Returns a vector mask where each element is true if the corresponding
element of self is less than or equal to the corresponding element of
other.
Equivalent to (self.x <= other.x, self.y <= other.y, ...).
§Examples
let vector = Vec3::new(1, 2, 3);
let mask = vector.le_mask(Vec3::new(0, 2, 5));
assert_eq!(mask, Mask3::new(false, true, true));Sourcepub fn ge_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialOrd,
pub fn ge_mask(self, other: Self) -> Mask<N, T, A>where
T: PartialOrd,
Returns a vector mask where each element is true if the corresponding
element of self is greater than or equal to the corresponding element
of other.
Equivalent to (self.x >= other.x, self.y >= other.y, ...).
§Examples
let vector = Vec3::new(1, 2, 3);
let mask = vector.ge_mask(Vec3::new(0, 2, 5));
assert_eq!(mask, Mask3::new(true, true, false));Sourcepub fn length_squared(self) -> T
pub fn length_squared(self) -> T
Sourcepub fn distance_squared(self, other: Self) -> T
pub fn distance_squared(self, other: Self) -> T
Computes the squared Euclidean distance between self and other.
§Panics
When debug assertions or overflow checks are enabled:
For integers this panics if an overflow occurs.
§Examples
let x = Vec3::<i32>::new(2, 0, 0);
let y = Vec3::<i32>::new(0, 3, 0);
assert_eq!(x.distance_squared(y), 13);
assert_eq!(x.distance_squared(x), 0);
assert_eq!(y.distance_squared(y), 0);Sourcepub const fn as_array_ref(&self) -> &[T; N]
👎Deprecated since 0.17.1: renamed to as_array
pub const fn as_array_ref(&self) -> &[T; N]
renamed to as_array
Returns a reference to the vector’s elements.
This function has been renamed to as_array.
Sourcepub const fn as_array_mut(&mut self) -> &mut [T; N]
👎Deprecated since 0.17.1: renamed to as_mut_array
pub const fn as_array_mut(&mut self) -> &mut [T; N]
renamed to as_mut_array
Returns a mutable reference to the vector’s elements.
This function has been renamed to as_mut_array.
Source§impl<T, A: Alignment> Vector<2, T, A>where
T: Scalar,
impl<T, A: Alignment> Vector<2, T, A>where
T: Scalar,
Sourcepub fn extend(self, value: T) -> Vector<3, T, A>
pub fn extend(self, value: T) -> Vector<3, T, A>
Returns a 3-dimensional vector containing the elements of self then
the scalar value.
Equivalent to (self, value).
Sourcepub fn perp(self) -> Selfwhere
T: Neg<Output = T>,
pub fn perp(self) -> Selfwhere
T: Neg<Output = T>,
Returns self rotated by 90 degrees.
This rotates +X to +Y.
§Examples
let x = Vec2::new(1, 0);
let y = Vec2::new(0, 1);
assert_eq!(x.perp(), y);
assert_eq!(y.perp(), -x);
assert_eq!((-x).perp(), -y);
assert_eq!((-y).perp(), x);Source§impl<T, A: Alignment> Vector<3, T, A>where
T: Scalar,
impl<T, A: Alignment> Vector<3, T, A>where
T: Scalar,
Sourcepub fn extend(self, value: T) -> Vector<4, T, A>
pub fn extend(self, value: T) -> Vector<4, T, A>
Returns a 4-dimensional vector containing the elements of self then
the scalar value.
Equivalent to (self, value).
Sourcepub fn truncate(self) -> Vector<2, T, A>
pub fn truncate(self) -> Vector<2, T, A>
Returns a 2-dimensional vector containing the first 2 elements of
self, discarding the last element.
Equivalent to self.xy.
Sourcepub fn to_homogeneous(self) -> Vector<4, T, A>where
T: One,
pub fn to_homogeneous(self) -> Vector<4, T, A>where
T: One,
Converts self to homogeneous coordinates.
Equivalent to self.extend(1).
Trait Implementations§
Source§impl<const N: usize, T, A: Alignment> Add for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Add for Vector<N, T, A>
Source§fn add(self, rhs: Self) -> Self::Output
fn add(self, rhs: Self) -> Self::Output
Performs the + operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a + Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 + 4, 2 + 5, 3 + 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Add<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Add<&T> for Vector<N, T, A>
Source§fn add(self, rhs: &T) -> Self::Output
fn add(self, rhs: &T) -> Self::Output
Performs the + operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a + 4;
assert_eq!(b, Vec3::new(1 + 4, 2 + 4, 3 + 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector + splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Add<&T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Add<&T> for &Vector<N, T, A>
Source§fn add(self, rhs: &T) -> Self::Output
fn add(self, rhs: &T) -> Self::Output
Performs the + operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a + 4;
assert_eq!(b, Vec3::new(1 + 4, 2 + 4, 3 + 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector + splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Add<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Add<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn add(self, rhs: &Vector<N, T, A>) -> Self::Output
fn add(self, rhs: &Vector<N, T, A>) -> Self::Output
Performs the + operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a + Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 + 4, 2 + 5, 3 + 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Add<&Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Add<&Vector<N, T, A>> for &Vector<N, T, A>
Source§fn add(self, rhs: &Vector<N, T, A>) -> Self::Output
fn add(self, rhs: &Vector<N, T, A>) -> Self::Output
Performs the + operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a + Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 + 4, 2 + 5, 3 + 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Add<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Add<T> for Vector<N, T, A>
Source§fn add(self, rhs: T) -> Self::Output
fn add(self, rhs: T) -> Self::Output
Performs the + operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a + 4;
assert_eq!(b, Vec3::new(1 + 4, 2 + 4, 3 + 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector + splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Add<T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Add<T> for &Vector<N, T, A>
Source§fn add(self, rhs: T) -> Self::Output
fn add(self, rhs: T) -> Self::Output
Performs the + operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a + 4;
assert_eq!(b, Vec3::new(1 + 4, 2 + 4, 3 + 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector + splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Add<Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Add<Vector<N, T, A>> for &Vector<N, T, A>
Source§fn add(self, rhs: Vector<N, T, A>) -> Self::Output
fn add(self, rhs: Vector<N, T, A>) -> Self::Output
Performs the + operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a + Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 + 4, 2 + 5, 3 + 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> AddAssign for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> AddAssign for Vector<N, T, A>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the += operation for each vector element.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector += Vec3::new(4, 5, 6);
assert_eq!(vector, Vec3::new(1 + 4, 2 + 5, 3 + 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector + vector.
Source§impl<const N: usize, T, A: Alignment> AddAssign<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> AddAssign<&T> for Vector<N, T, A>
Source§fn add_assign(&mut self, rhs: &T)
fn add_assign(&mut self, rhs: &T)
Performs the += operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector += 4;
assert_eq!(vector, Vec3::new(1 + 4, 2 + 4, 3 + 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector + vector.
Source§impl<const N: usize, T, A: Alignment> AddAssign<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> AddAssign<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn add_assign(&mut self, rhs: &Vector<N, T, A>)
fn add_assign(&mut self, rhs: &Vector<N, T, A>)
Performs the += operation for each vector element.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector += Vec3::new(4, 5, 6);
assert_eq!(vector, Vec3::new(1 + 4, 2 + 5, 3 + 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector + vector.
Source§impl<const N: usize, T, A: Alignment> AddAssign<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> AddAssign<T> for Vector<N, T, A>
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Performs the += operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector += 4;
assert_eq!(vector, Vec3::new(1 + 4, 2 + 4, 3 + 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector + vector.
Source§impl<const N: usize, T, A: Alignment> BitAnd for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitAnd for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitAnd<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitAnd<&T> for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitAnd<&T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitAnd<&T> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitAnd<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitAnd<&Vector<N, T, A>> for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitAnd<&Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitAnd<&Vector<N, T, A>> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitAnd<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitAnd<T> for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitAnd<T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitAnd<T> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitAnd<Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitAnd<Vector<N, T, A>> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitAndAssign for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitAndAssign for Vector<N, T, A>
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
Source§impl<const N: usize, T, A: Alignment> BitAndAssign<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitAndAssign<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn bitand_assign(&mut self, rhs: &Vector<N, T, A>)
fn bitand_assign(&mut self, rhs: &Vector<N, T, A>)
Source§impl<const N: usize, T, A: Alignment> BitAndAssign<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitAndAssign<T> for Vector<N, T, A>
Source§fn bitand_assign(&mut self, rhs: T)
fn bitand_assign(&mut self, rhs: T)
Source§impl<const N: usize, T, A: Alignment> BitOr<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitOr<&T> for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitOr<&T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitOr<&T> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitOr<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitOr<&Vector<N, T, A>> for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitOr<&Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitOr<&Vector<N, T, A>> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitOr<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitOr<T> for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitOr<T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitOr<T> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitOr<Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitOr<Vector<N, T, A>> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitOrAssign for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitOrAssign for Vector<N, T, A>
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
Source§impl<const N: usize, T, A: Alignment> BitOrAssign<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitOrAssign<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn bitor_assign(&mut self, rhs: &Vector<N, T, A>)
fn bitor_assign(&mut self, rhs: &Vector<N, T, A>)
Source§impl<const N: usize, T, A: Alignment> BitOrAssign<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitOrAssign<T> for Vector<N, T, A>
Source§fn bitor_assign(&mut self, rhs: T)
fn bitor_assign(&mut self, rhs: T)
Source§impl<const N: usize, T, A: Alignment> BitXor for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitXor for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitXor<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitXor<&T> for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitXor<&T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitXor<&T> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitXor<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitXor<&Vector<N, T, A>> for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitXor<&Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitXor<&Vector<N, T, A>> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitXor<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitXor<T> for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitXor<T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitXor<T> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitXor<Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitXor<Vector<N, T, A>> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> BitXorAssign for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitXorAssign for Vector<N, T, A>
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
Source§impl<const N: usize, T, A: Alignment> BitXorAssign<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitXorAssign<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn bitxor_assign(&mut self, rhs: &Vector<N, T, A>)
fn bitxor_assign(&mut self, rhs: &Vector<N, T, A>)
Source§impl<const N: usize, T, A: Alignment> BitXorAssign<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> BitXorAssign<T> for Vector<N, T, A>
Source§fn bitxor_assign(&mut self, rhs: T)
fn bitxor_assign(&mut self, rhs: T)
impl<const N: usize, T, A: Alignment> Copy for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> Div for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Div for Vector<N, T, A>
Source§fn div(self, rhs: Self) -> Self::Output
fn div(self, rhs: Self) -> Self::Output
Performs the / operation for each vector element.
§Examples
let a = Vec3::new(8, 10, 12);
let b = a / Vec3::new(2, 5, 3);
assert_eq!(b, Vec3::new(8 / 2, 10 / 5, 12 / 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Div<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Div<&T> for Vector<N, T, A>
Source§fn div(self, rhs: &T) -> Self::Output
fn div(self, rhs: &T) -> Self::Output
Performs the / operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(8, 10, 12);
let b = a / 2;
assert_eq!(b, Vec3::new(8 / 2, 10 / 2, 12 / 2));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector / splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Div<&T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Div<&T> for &Vector<N, T, A>
Source§fn div(self, rhs: &T) -> Self::Output
fn div(self, rhs: &T) -> Self::Output
Performs the / operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(8, 10, 12);
let b = a / 2;
assert_eq!(b, Vec3::new(8 / 2, 10 / 2, 12 / 2));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector / splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Div<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Div<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn div(self, rhs: &Vector<N, T, A>) -> Self::Output
fn div(self, rhs: &Vector<N, T, A>) -> Self::Output
Performs the / operation for each vector element.
§Examples
let a = Vec3::new(8, 10, 12);
let b = a / Vec3::new(2, 5, 3);
assert_eq!(b, Vec3::new(8 / 2, 10 / 5, 12 / 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Div<&Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Div<&Vector<N, T, A>> for &Vector<N, T, A>
Source§fn div(self, rhs: &Vector<N, T, A>) -> Self::Output
fn div(self, rhs: &Vector<N, T, A>) -> Self::Output
Performs the / operation for each vector element.
§Examples
let a = Vec3::new(8, 10, 12);
let b = a / Vec3::new(2, 5, 3);
assert_eq!(b, Vec3::new(8 / 2, 10 / 5, 12 / 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Div<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Div<T> for Vector<N, T, A>
Source§fn div(self, rhs: T) -> Self::Output
fn div(self, rhs: T) -> Self::Output
Performs the / operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(8, 10, 12);
let b = a / 2;
assert_eq!(b, Vec3::new(8 / 2, 10 / 2, 12 / 2));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector / splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Div<T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Div<T> for &Vector<N, T, A>
Source§fn div(self, rhs: T) -> Self::Output
fn div(self, rhs: T) -> Self::Output
Performs the / operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(8, 10, 12);
let b = a / 2;
assert_eq!(b, Vec3::new(8 / 2, 10 / 2, 12 / 2));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector / splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Div<Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Div<Vector<N, T, A>> for &Vector<N, T, A>
Source§fn div(self, rhs: Vector<N, T, A>) -> Self::Output
fn div(self, rhs: Vector<N, T, A>) -> Self::Output
Performs the / operation for each vector element.
§Examples
let a = Vec3::new(8, 10, 12);
let b = a / Vec3::new(2, 5, 3);
assert_eq!(b, Vec3::new(8 / 2, 10 / 5, 12 / 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> DivAssign for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> DivAssign for Vector<N, T, A>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the /= operation for each vector element.
§Examples
let mut vector = Vec3::new(8, 10, 12);
vector /= Vec3::new(2, 5, 3);
assert_eq!(vector, Vec3::new(8 / 2, 10 / 5, 12 / 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector / vector.
Source§impl<const N: usize, T, A: Alignment> DivAssign<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> DivAssign<&T> for Vector<N, T, A>
Source§fn div_assign(&mut self, rhs: &T)
fn div_assign(&mut self, rhs: &T)
Performs the /= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(8, 10, 12);
vector /= 2;
assert_eq!(vector, Vec3::new(8 / 2, 10 / 2, 12 / 2));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector / vector.
Source§impl<const N: usize, T, A: Alignment> DivAssign<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> DivAssign<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn div_assign(&mut self, rhs: &Vector<N, T, A>)
fn div_assign(&mut self, rhs: &Vector<N, T, A>)
Performs the /= operation for each vector element.
§Examples
let mut vector = Vec3::new(8, 10, 12);
vector /= Vec3::new(2, 5, 3);
assert_eq!(vector, Vec3::new(8 / 2, 10 / 5, 12 / 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector / vector.
Source§impl<const N: usize, T, A: Alignment> DivAssign<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> DivAssign<T> for Vector<N, T, A>
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the /= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(8, 10, 12);
vector /= 2;
assert_eq!(vector, Vec3::new(8 / 2, 10 / 2, 12 / 2));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector / vector.
impl<const N: usize, T, A: Alignment> Eq for Vector<N, T, A>
Source§impl<T, A: Alignment> From<(T, T, T, T)> for Vector<4, T, A>where
T: Scalar,
impl<T, A: Alignment> From<(T, T, T, T)> for Vector<4, T, A>where
T: Scalar,
Source§fn from(value: (T, T, T, T)) -> Self
fn from(value: (T, T, T, T)) -> Self
Source§impl<T, A: Alignment> From<(Vector<2, T, A>, Vector<2, T, A>)> for Vector<4, T, A>where
T: Scalar,
impl<T, A: Alignment> From<(Vector<2, T, A>, Vector<2, T, A>)> for Vector<4, T, A>where
T: Scalar,
Source§impl<const N: usize, T, A: Alignment> Mul for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul for Vector<N, T, A>
Source§fn mul(self, rhs: Self) -> Self::Output
fn mul(self, rhs: Self) -> Self::Output
Performs the * operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a * Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 * 4, 2 * 5, 3 * 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Mul<&Matrix<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul<&Matrix<N, T, A>> for Vector<N, T, A>
Source§fn mul(self, rhs: &Matrix<N, T, A>) -> Self::Output
fn mul(self, rhs: &Matrix<N, T, A>) -> Self::Output
Vector-matrix multiplication.
Because vectors are treated as row matrices, they always go on the left-hand side.
Equivalent to self.x * rhs.x_axis + self.y * rhs.y_axis + ....
§Consistency
For primitive types this operation is cross-platform deterministic and fully consistent with scalar addition and multiplication, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Mul<&Matrix<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul<&Matrix<N, T, A>> for &Vector<N, T, A>
Source§fn mul(self, rhs: &Matrix<N, T, A>) -> Self::Output
fn mul(self, rhs: &Matrix<N, T, A>) -> Self::Output
Vector-matrix multiplication.
Because vectors are treated as row matrices, they always go on the left-hand side.
Equivalent to self.x * rhs.x_axis + self.y * rhs.y_axis + ....
§Consistency
For primitive types this operation is cross-platform deterministic and fully consistent with scalar addition and multiplication, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Mul<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul<&T> for Vector<N, T, A>
Source§fn mul(self, rhs: &T) -> Self::Output
fn mul(self, rhs: &T) -> Self::Output
Performs the * operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a * 4;
assert_eq!(b, Vec3::new(1 * 4, 2 * 4, 3 * 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector * splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Mul<&T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul<&T> for &Vector<N, T, A>
Source§fn mul(self, rhs: &T) -> Self::Output
fn mul(self, rhs: &T) -> Self::Output
Performs the * operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a * 4;
assert_eq!(b, Vec3::new(1 * 4, 2 * 4, 3 * 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector * splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Mul<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn mul(self, rhs: &Vector<N, T, A>) -> Self::Output
fn mul(self, rhs: &Vector<N, T, A>) -> Self::Output
Performs the * operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a * Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 * 4, 2 * 5, 3 * 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Mul<&Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul<&Vector<N, T, A>> for &Vector<N, T, A>
Source§fn mul(self, rhs: &Vector<N, T, A>) -> Self::Output
fn mul(self, rhs: &Vector<N, T, A>) -> Self::Output
Performs the * operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a * Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 * 4, 2 * 5, 3 * 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Mul<Matrix<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul<Matrix<N, T, A>> for Vector<N, T, A>
Source§fn mul(self, rhs: Matrix<N, T, A>) -> Self::Output
fn mul(self, rhs: Matrix<N, T, A>) -> Self::Output
Vector-matrix multiplication.
Because vectors are treated as row matrices, they always go on the left-hand side.
Equivalent to self.x * rhs.x_axis + self.y * rhs.y_axis + ....
§Consistency
For primitive types this operation is cross-platform deterministic and fully consistent with scalar addition and multiplication, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Mul<Matrix<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul<Matrix<N, T, A>> for &Vector<N, T, A>
Source§fn mul(self, rhs: Matrix<N, T, A>) -> Self::Output
fn mul(self, rhs: Matrix<N, T, A>) -> Self::Output
Vector-matrix multiplication.
Because vectors are treated as row matrices, they always go on the left-hand side.
Equivalent to self.x * rhs.x_axis + self.y * rhs.y_axis + ....
§Consistency
For primitive types this operation is cross-platform deterministic and fully consistent with scalar addition and multiplication, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Mul<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul<T> for Vector<N, T, A>
Source§fn mul(self, rhs: T) -> Self::Output
fn mul(self, rhs: T) -> Self::Output
Performs the * operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a * 4;
assert_eq!(b, Vec3::new(1 * 4, 2 * 4, 3 * 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector * splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Mul<T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul<T> for &Vector<N, T, A>
Source§fn mul(self, rhs: T) -> Self::Output
fn mul(self, rhs: T) -> Self::Output
Performs the * operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a * 4;
assert_eq!(b, Vec3::new(1 * 4, 2 * 4, 3 * 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector * splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Mul<Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Mul<Vector<N, T, A>> for &Vector<N, T, A>
Source§fn mul(self, rhs: Vector<N, T, A>) -> Self::Output
fn mul(self, rhs: Vector<N, T, A>) -> Self::Output
Performs the * operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a * Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 * 4, 2 * 5, 3 * 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> MulAssign for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> MulAssign for Vector<N, T, A>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the *= operation for each vector element.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector *= Vec3::new(4, 5, 6);
assert_eq!(vector, Vec3::new(1 * 4, 2 * 5, 3 * 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector * vector.
Source§impl<const N: usize, T, A: Alignment> MulAssign<&Matrix<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> MulAssign<&Matrix<N, T, A>> for Vector<N, T, A>
Source§fn mul_assign(&mut self, rhs: &Matrix<N, T, A>)
fn mul_assign(&mut self, rhs: &Matrix<N, T, A>)
Vector-matrix multiplication.
Because vectors are treated as row matrices, they always go on the left-hand side.
Equivalent to self.x * rhs.x_axis + self.y * rhs.y_axis + ....
§Consistency
For primitive types this operation is cross-platform deterministic and fully consistent with scalar addition and multiplication, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> MulAssign<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> MulAssign<&T> for Vector<N, T, A>
Source§fn mul_assign(&mut self, rhs: &T)
fn mul_assign(&mut self, rhs: &T)
Performs the *= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector *= 4;
assert_eq!(vector, Vec3::new(1 * 4, 2 * 4, 3 * 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector * vector.
Source§impl<const N: usize, T, A: Alignment> MulAssign<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> MulAssign<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn mul_assign(&mut self, rhs: &Vector<N, T, A>)
fn mul_assign(&mut self, rhs: &Vector<N, T, A>)
Performs the *= operation for each vector element.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector *= Vec3::new(4, 5, 6);
assert_eq!(vector, Vec3::new(1 * 4, 2 * 5, 3 * 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector * vector.
Source§impl<const N: usize, T, A: Alignment> MulAssign<Matrix<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> MulAssign<Matrix<N, T, A>> for Vector<N, T, A>
Source§fn mul_assign(&mut self, rhs: Matrix<N, T, A>)
fn mul_assign(&mut self, rhs: Matrix<N, T, A>)
Vector-matrix multiplication.
Because vectors are treated as row matrices, they always go on the left-hand side.
Equivalent to self.x * rhs.x_axis + self.y * rhs.y_axis + ....
§Consistency
For primitive types this operation is cross-platform deterministic and fully consistent with scalar addition and multiplication, including floating-point precision and integer panics.
Source§impl<T, A: Alignment> MulAssign<Quaternion<T, A>> for Vector<3, T, A>
impl<T, A: Alignment> MulAssign<Quaternion<T, A>> for Vector<3, T, A>
Source§fn mul_assign(&mut self, rhs: Quaternion<T, A>)
fn mul_assign(&mut self, rhs: Quaternion<T, A>)
3D vector quaternion multiplication. Returns the rotated vector.
Source§impl<const N: usize, T, A: Alignment> MulAssign<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> MulAssign<T> for Vector<N, T, A>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the *= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector *= 4;
assert_eq!(vector, Vec3::new(1 * 4, 2 * 4, 3 * 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector * vector.
Source§impl<const N: usize, T, A: Alignment> Neg for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Neg for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> Neg for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Neg for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> RefUnwindSafe for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> Rem for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Rem for Vector<N, T, A>
Source§fn rem(self, rhs: Self) -> Self::Output
fn rem(self, rhs: Self) -> Self::Output
Performs the % operation for each vector element.
§Examples
let a = Vec3::new(5, 7, 9);
let b = a % Vec3::new(2, 3, 4);
assert_eq!(b, Vec3::new(5 % 2, 7 % 3, 9 % 4));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
Source§impl<const N: usize, T, A: Alignment> Rem<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Rem<&T> for Vector<N, T, A>
Source§fn rem(self, rhs: &T) -> Self::Output
fn rem(self, rhs: &T) -> Self::Output
Performs the % operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(5, 7, 9);
let b = a % 2;
assert_eq!(b, Vec3::new(5 % 2, 7 % 2, 9 % 2));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
This operation is fully consistent with vector % splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Rem<&T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Rem<&T> for &Vector<N, T, A>
Source§fn rem(self, rhs: &T) -> Self::Output
fn rem(self, rhs: &T) -> Self::Output
Performs the % operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(5, 7, 9);
let b = a % 2;
assert_eq!(b, Vec3::new(5 % 2, 7 % 2, 9 % 2));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
This operation is fully consistent with vector % splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Rem<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Rem<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn rem(self, rhs: &Vector<N, T, A>) -> Self::Output
fn rem(self, rhs: &Vector<N, T, A>) -> Self::Output
Performs the % operation for each vector element.
§Examples
let a = Vec3::new(5, 7, 9);
let b = a % Vec3::new(2, 3, 4);
assert_eq!(b, Vec3::new(5 % 2, 7 % 3, 9 % 4));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
Source§impl<const N: usize, T, A: Alignment> Rem<&Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Rem<&Vector<N, T, A>> for &Vector<N, T, A>
Source§fn rem(self, rhs: &Vector<N, T, A>) -> Self::Output
fn rem(self, rhs: &Vector<N, T, A>) -> Self::Output
Performs the % operation for each vector element.
§Examples
let a = Vec3::new(5, 7, 9);
let b = a % Vec3::new(2, 3, 4);
assert_eq!(b, Vec3::new(5 % 2, 7 % 3, 9 % 4));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
Source§impl<const N: usize, T, A: Alignment> Rem<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Rem<T> for Vector<N, T, A>
Source§fn rem(self, rhs: T) -> Self::Output
fn rem(self, rhs: T) -> Self::Output
Performs the % operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(5, 7, 9);
let b = a % 2;
assert_eq!(b, Vec3::new(5 % 2, 7 % 2, 9 % 2));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
This operation is fully consistent with vector % splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Rem<T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Rem<T> for &Vector<N, T, A>
Source§fn rem(self, rhs: T) -> Self::Output
fn rem(self, rhs: T) -> Self::Output
Performs the % operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(5, 7, 9);
let b = a % 2;
assert_eq!(b, Vec3::new(5 % 2, 7 % 2, 9 % 2));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
This operation is fully consistent with vector % splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Rem<Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Rem<Vector<N, T, A>> for &Vector<N, T, A>
Source§fn rem(self, rhs: Vector<N, T, A>) -> Self::Output
fn rem(self, rhs: Vector<N, T, A>) -> Self::Output
Performs the % operation for each vector element.
§Examples
let a = Vec3::new(5, 7, 9);
let b = a % Vec3::new(2, 3, 4);
assert_eq!(b, Vec3::new(5 % 2, 7 % 3, 9 % 4));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
Source§impl<const N: usize, T, A: Alignment> RemAssign for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> RemAssign for Vector<N, T, A>
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
Performs the %= operation for each vector element.
§Examples
let mut vector = Vec3::new(5, 7, 9);
vector %= Vec3::new(2, 3, 4);
assert_eq!(vector, Vec3::new(5 % 2, 7 % 3, 9 % 4));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
This operation is fully consistent with vector % vector.
Source§impl<const N: usize, T, A: Alignment> RemAssign<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> RemAssign<&T> for Vector<N, T, A>
Source§fn rem_assign(&mut self, rhs: &T)
fn rem_assign(&mut self, rhs: &T)
Performs the %= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(5, 7, 9);
vector %= 2;
assert_eq!(vector, Vec3::new(5 % 2, 7 % 2, 9 % 2));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
This operation is fully consistent with vector % vector.
Source§impl<const N: usize, T, A: Alignment> RemAssign<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> RemAssign<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn rem_assign(&mut self, rhs: &Vector<N, T, A>)
fn rem_assign(&mut self, rhs: &Vector<N, T, A>)
Performs the %= operation for each vector element.
§Examples
let mut vector = Vec3::new(5, 7, 9);
vector %= Vec3::new(2, 3, 4);
assert_eq!(vector, Vec3::new(5 % 2, 7 % 3, 9 % 4));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
This operation is fully consistent with vector % vector.
Source§impl<const N: usize, T, A: Alignment> RemAssign<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> RemAssign<T> for Vector<N, T, A>
Source§fn rem_assign(&mut self, rhs: T)
fn rem_assign(&mut self, rhs: T)
Performs the %= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(5, 7, 9);
vector %= 2;
assert_eq!(vector, Vec3::new(5 % 2, 7 % 2, 9 % 2));§Consistency
For integers this operation is fully consistent with the scalar operation, including panics.
For floats this operation may be inconsistent with the scalar operation, regarding precision and NaN propagation.
This operation is fully consistent with vector % vector.
impl<const N: usize, T, A: Alignment> Send for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> Shl for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shl for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> Shl<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shl<&T> for Vector<N, T, A>
Source§fn shl(self, rhs: &T) -> Self::Output
fn shl(self, rhs: &T) -> Self::Output
Performs the << operation for each vector element and the scalar
rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a << 1;
assert_eq!(b, Vec3::new(1 << 1, 2 << 1, 3 << 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector << splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Shl<&T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shl<&T> for &Vector<N, T, A>
Source§fn shl(self, rhs: &T) -> Self::Output
fn shl(self, rhs: &T) -> Self::Output
Performs the << operation for each vector element and the scalar
rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a << 1;
assert_eq!(b, Vec3::new(1 << 1, 2 << 1, 3 << 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector << splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Shl<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shl<&Vector<N, T, A>> for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> Shl<&Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shl<&Vector<N, T, A>> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> Shl<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shl<T> for Vector<N, T, A>
Source§fn shl(self, rhs: T) -> Self::Output
fn shl(self, rhs: T) -> Self::Output
Performs the << operation for each vector element and the scalar
rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a << 1;
assert_eq!(b, Vec3::new(1 << 1, 2 << 1, 3 << 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector << splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Shl<T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shl<T> for &Vector<N, T, A>
Source§fn shl(self, rhs: T) -> Self::Output
fn shl(self, rhs: T) -> Self::Output
Performs the << operation for each vector element and the scalar
rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a << 1;
assert_eq!(b, Vec3::new(1 << 1, 2 << 1, 3 << 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector << splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Shl<Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shl<Vector<N, T, A>> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> ShlAssign for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> ShlAssign for Vector<N, T, A>
Source§fn shl_assign(&mut self, rhs: Self)
fn shl_assign(&mut self, rhs: Self)
Performs the <<= operation for each vector element.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector <<= Vec3::new(1, 2, 3);
assert_eq!(vector, Vec3::new(1 << 1, 2 << 2, 3 << 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector << vector.
Source§impl<const N: usize, T, A: Alignment> ShlAssign<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> ShlAssign<&T> for Vector<N, T, A>
Source§fn shl_assign(&mut self, rhs: &T)
fn shl_assign(&mut self, rhs: &T)
Performs the <<= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector <<= 1;
assert_eq!(vector, Vec3::new(1 << 1, 2 << 1, 3 << 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector << vector.
Source§impl<const N: usize, T, A: Alignment> ShlAssign<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> ShlAssign<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn shl_assign(&mut self, rhs: &Vector<N, T, A>)
fn shl_assign(&mut self, rhs: &Vector<N, T, A>)
Performs the <<= operation for each vector element.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector <<= Vec3::new(1, 2, 3);
assert_eq!(vector, Vec3::new(1 << 1, 2 << 2, 3 << 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector << vector.
Source§impl<const N: usize, T, A: Alignment> ShlAssign<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> ShlAssign<T> for Vector<N, T, A>
Source§fn shl_assign(&mut self, rhs: T)
fn shl_assign(&mut self, rhs: T)
Performs the <<= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(1, 2, 3);
vector <<= 1;
assert_eq!(vector, Vec3::new(1 << 1, 2 << 1, 3 << 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector << vector.
Source§impl<const N: usize, T, A: Alignment> Shr for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shr for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> Shr<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shr<&T> for Vector<N, T, A>
Source§fn shr(self, rhs: &T) -> Self::Output
fn shr(self, rhs: &T) -> Self::Output
Performs the >> operation for each vector element and the scalar
rhs.
§Examples
let a = Vec3::new(8, 16, 32);
let b = a >> 1;
assert_eq!(b, Vec3::new(8 >> 1, 16 >> 1, 32 >> 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector >> splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Shr<&T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shr<&T> for &Vector<N, T, A>
Source§fn shr(self, rhs: &T) -> Self::Output
fn shr(self, rhs: &T) -> Self::Output
Performs the >> operation for each vector element and the scalar
rhs.
§Examples
let a = Vec3::new(8, 16, 32);
let b = a >> 1;
assert_eq!(b, Vec3::new(8 >> 1, 16 >> 1, 32 >> 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector >> splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Shr<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shr<&Vector<N, T, A>> for Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> Shr<&Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shr<&Vector<N, T, A>> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> Shr<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shr<T> for Vector<N, T, A>
Source§fn shr(self, rhs: T) -> Self::Output
fn shr(self, rhs: T) -> Self::Output
Performs the >> operation for each vector element and the scalar
rhs.
§Examples
let a = Vec3::new(8, 16, 32);
let b = a >> 1;
assert_eq!(b, Vec3::new(8 >> 1, 16 >> 1, 32 >> 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector >> splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Shr<T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shr<T> for &Vector<N, T, A>
Source§fn shr(self, rhs: T) -> Self::Output
fn shr(self, rhs: T) -> Self::Output
Performs the >> operation for each vector element and the scalar
rhs.
§Examples
let a = Vec3::new(8, 16, 32);
let b = a >> 1;
assert_eq!(b, Vec3::new(8 >> 1, 16 >> 1, 32 >> 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector >> splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Shr<Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Shr<Vector<N, T, A>> for &Vector<N, T, A>
Source§impl<const N: usize, T, A: Alignment> ShrAssign for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> ShrAssign for Vector<N, T, A>
Source§fn shr_assign(&mut self, rhs: Self)
fn shr_assign(&mut self, rhs: Self)
Performs the >>= operation for each vector element.
§Examples
let mut vector = Vec3::new(8, 16, 32);
vector >>= Vec3::new(1, 2, 3);
assert_eq!(vector, Vec3::new(8 >> 1, 16 >> 2, 32 >> 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector >> vector.
Source§impl<const N: usize, T, A: Alignment> ShrAssign<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> ShrAssign<&T> for Vector<N, T, A>
Source§fn shr_assign(&mut self, rhs: &T)
fn shr_assign(&mut self, rhs: &T)
Performs the >>= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(8, 16, 32);
vector >>= 1;
assert_eq!(vector, Vec3::new(8 >> 1, 16 >> 1, 32 >> 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector >> vector.
Source§impl<const N: usize, T, A: Alignment> ShrAssign<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> ShrAssign<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn shr_assign(&mut self, rhs: &Vector<N, T, A>)
fn shr_assign(&mut self, rhs: &Vector<N, T, A>)
Performs the >>= operation for each vector element.
§Examples
let mut vector = Vec3::new(8, 16, 32);
vector >>= Vec3::new(1, 2, 3);
assert_eq!(vector, Vec3::new(8 >> 1, 16 >> 2, 32 >> 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector >> vector.
Source§impl<const N: usize, T, A: Alignment> ShrAssign<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> ShrAssign<T> for Vector<N, T, A>
Source§fn shr_assign(&mut self, rhs: T)
fn shr_assign(&mut self, rhs: T)
Performs the >>= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(8, 16, 32);
vector >>= 1;
assert_eq!(vector, Vec3::new(8 >> 1, 16 >> 1, 32 >> 1));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including integer panics.
This operation is fully consistent with vector >> vector.
Source§impl<const N: usize, T, A: Alignment> Sub for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Sub for Vector<N, T, A>
Source§fn sub(self, rhs: Self) -> Self::Output
fn sub(self, rhs: Self) -> Self::Output
Performs the - operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a - Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 - 4, 2 - 5, 3 - 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Sub<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Sub<&T> for Vector<N, T, A>
Source§fn sub(self, rhs: &T) -> Self::Output
fn sub(self, rhs: &T) -> Self::Output
Performs the - operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a - 4;
assert_eq!(b, Vec3::new(1 - 4, 2 - 4, 3 - 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector - splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Sub<&T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Sub<&T> for &Vector<N, T, A>
Source§fn sub(self, rhs: &T) -> Self::Output
fn sub(self, rhs: &T) -> Self::Output
Performs the - operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a - 4;
assert_eq!(b, Vec3::new(1 - 4, 2 - 4, 3 - 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector - splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Sub<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Sub<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn sub(self, rhs: &Vector<N, T, A>) -> Self::Output
fn sub(self, rhs: &Vector<N, T, A>) -> Self::Output
Performs the - operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a - Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 - 4, 2 - 5, 3 - 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Sub<&Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Sub<&Vector<N, T, A>> for &Vector<N, T, A>
Source§fn sub(self, rhs: &Vector<N, T, A>) -> Self::Output
fn sub(self, rhs: &Vector<N, T, A>) -> Self::Output
Performs the - operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a - Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 - 4, 2 - 5, 3 - 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> Sub<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Sub<T> for Vector<N, T, A>
Source§fn sub(self, rhs: T) -> Self::Output
fn sub(self, rhs: T) -> Self::Output
Performs the - operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a - 4;
assert_eq!(b, Vec3::new(1 - 4, 2 - 4, 3 - 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector - splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Sub<T> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Sub<T> for &Vector<N, T, A>
Source§fn sub(self, rhs: T) -> Self::Output
fn sub(self, rhs: T) -> Self::Output
Performs the - operation for each vector element and the scalar rhs.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a - 4;
assert_eq!(b, Vec3::new(1 - 4, 2 - 4, 3 - 4));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector - splat(scalar).
Source§impl<const N: usize, T, A: Alignment> Sub<Vector<N, T, A>> for &Vector<N, T, A>
impl<const N: usize, T, A: Alignment> Sub<Vector<N, T, A>> for &Vector<N, T, A>
Source§fn sub(self, rhs: Vector<N, T, A>) -> Self::Output
fn sub(self, rhs: Vector<N, T, A>) -> Self::Output
Performs the - operation for each vector element.
§Examples
let a = Vec3::new(1, 2, 3);
let b = a - Vec3::new(4, 5, 6);
assert_eq!(b, Vec3::new(1 - 4, 2 - 5, 3 - 6));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
Source§impl<const N: usize, T, A: Alignment> SubAssign for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> SubAssign for Vector<N, T, A>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the -= operation for each vector element.
§Examples
let mut vector = Vec3::new(5, 7, 9);
vector -= Vec3::new(1, 2, 3);
assert_eq!(vector, Vec3::new(5 - 1, 7 - 2, 9 - 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector - vector.
Source§impl<const N: usize, T, A: Alignment> SubAssign<&T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> SubAssign<&T> for Vector<N, T, A>
Source§fn sub_assign(&mut self, rhs: &T)
fn sub_assign(&mut self, rhs: &T)
Performs the -= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(5, 7, 9);
vector -= 2;
assert_eq!(vector, Vec3::new(5 - 2, 7 - 2, 9 - 2));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector - vector.
Source§impl<const N: usize, T, A: Alignment> SubAssign<&Vector<N, T, A>> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> SubAssign<&Vector<N, T, A>> for Vector<N, T, A>
Source§fn sub_assign(&mut self, rhs: &Vector<N, T, A>)
fn sub_assign(&mut self, rhs: &Vector<N, T, A>)
Performs the -= operation for each vector element.
§Examples
let mut vector = Vec3::new(5, 7, 9);
vector -= Vec3::new(1, 2, 3);
assert_eq!(vector, Vec3::new(5 - 1, 7 - 2, 9 - 3));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector - vector.
Source§impl<const N: usize, T, A: Alignment> SubAssign<T> for Vector<N, T, A>
impl<const N: usize, T, A: Alignment> SubAssign<T> for Vector<N, T, A>
Source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
Performs the -= operation for each vector element and the scalar
rhs.
§Examples
let mut vector = Vec3::new(5, 7, 9);
vector -= 2;
assert_eq!(vector, Vec3::new(5 - 2, 7 - 2, 9 - 2));§Consistency
For primitive types this operation is fully consistent with the scalar operation, including floating-point precision and integer panics.
This operation is fully consistent with vector - vector.