#[repr(transparent)]pub struct Vector<T, const D: usize> {
pub coords: [T; D],
}
alg
only.Expand description
A static D
-dimensional vector, backed by a primitive array
.
Fields§
§coords: [T; D]
The vector coordinates in some basis.
Implementations§
Source§impl<const D: usize> Vector<i8, D>
§Methods for vectors represented using i8
.
impl<const D: usize> Vector<i8, D>
§Methods for vectors represented using i8
.
Sourcepub const fn c_normalize_with(self, magnitude: i8) -> Self
Available on crate feature _int_i8
only.
pub const fn c_normalize_with(self, magnitude: i8) -> Self
_int_i8
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> i8 ⓘ
Available on crate feature _int_i8
only.
pub const fn c_magnitude_sq(self) -> i8 ⓘ
_int_i8
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_i8
only.
pub const fn c_add(self, other: Self) -> Self
_int_i8
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_i8
only.
pub const fn c_sub(self, other: Self) -> Self
_int_i8
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> i8 ⓘ
Available on crate feature _int_i8
only.
pub const fn c_dot(self, other: Self) -> i8 ⓘ
_int_i8
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: i8) -> Self
Available on crate feature _int_i8
only.
pub const fn c_scalar_mul(self, scalar: i8) -> Self
_int_i8
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: i8) -> Self
Available on crate feature _int_i8
only.
pub const fn c_scalar_div(self, scalar: i8) -> Self
_int_i8
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<i8, 3>
§Methods for 3d vectors represented using i8
.
impl Vector<i8, 3>
§Methods for 3d vectors represented using i8
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<i8, D>
§Methods for vectors represented using i8
, signed.
impl<const D: usize> Vector<i8, D>
§Methods for vectors represented using i8
, signed.
Sourcepub const NEG_ONE: Self
Available on crate feature _int_i8
only.
pub const NEG_ONE: Self
_int_i8
only.A Vector
with all negative ones.
Sourcepub const fn c_magnitude_floor(self) -> i8 ⓘ
Available on crate feature _int_i8
only.
pub const fn c_magnitude_floor(self) -> i8 ⓘ
_int_i8
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
§Features
This will only be const if the “_cmp_i8” feature is enabled.
Sourcepub const fn c_magnitude_ceil(self) -> i8 ⓘ
Available on crate feature _int_i8
only.
pub const fn c_magnitude_ceil(self) -> i8 ⓘ
_int_i8
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
§Features
This will only be const if the “_cmp_i8” feature is enabled.
Sourcepub const fn c_magnitude_round(self) -> i8 ⓘ
Available on crate feature _int_i8
only.
pub const fn c_magnitude_round(self) -> i8 ⓘ
_int_i8
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a i128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<i16, D>
§Methods for vectors represented using i16
.
impl<const D: usize> Vector<i16, D>
§Methods for vectors represented using i16
.
Sourcepub const fn c_normalize_with(self, magnitude: i16) -> Self
Available on crate feature _int_i16
only.
pub const fn c_normalize_with(self, magnitude: i16) -> Self
_int_i16
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> i16 ⓘ
Available on crate feature _int_i16
only.
pub const fn c_magnitude_sq(self) -> i16 ⓘ
_int_i16
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_i16
only.
pub const fn c_add(self, other: Self) -> Self
_int_i16
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_i16
only.
pub const fn c_sub(self, other: Self) -> Self
_int_i16
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> i16 ⓘ
Available on crate feature _int_i16
only.
pub const fn c_dot(self, other: Self) -> i16 ⓘ
_int_i16
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: i16) -> Self
Available on crate feature _int_i16
only.
pub const fn c_scalar_mul(self, scalar: i16) -> Self
_int_i16
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: i16) -> Self
Available on crate feature _int_i16
only.
pub const fn c_scalar_div(self, scalar: i16) -> Self
_int_i16
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<i16, 3>
§Methods for 3d vectors represented using i16
.
impl Vector<i16, 3>
§Methods for 3d vectors represented using i16
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<i16, D>
§Methods for vectors represented using i16
, signed.
impl<const D: usize> Vector<i16, D>
§Methods for vectors represented using i16
, signed.
Sourcepub const NEG_ONE: Self
Available on crate feature _int_i16
only.
pub const NEG_ONE: Self
_int_i16
only.A Vector
with all negative ones.
Sourcepub const fn c_magnitude_floor(self) -> i16 ⓘ
Available on crate feature _int_i16
only.
pub const fn c_magnitude_floor(self) -> i16 ⓘ
_int_i16
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
§Features
This will only be const if the “_cmp_i16” feature is enabled.
Sourcepub const fn c_magnitude_ceil(self) -> i16 ⓘ
Available on crate feature _int_i16
only.
pub const fn c_magnitude_ceil(self) -> i16 ⓘ
_int_i16
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
§Features
This will only be const if the “_cmp_i16” feature is enabled.
Sourcepub const fn c_magnitude_round(self) -> i16 ⓘ
Available on crate feature _int_i16
only.
pub const fn c_magnitude_round(self) -> i16 ⓘ
_int_i16
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a i128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<i32, D>
§Methods for vectors represented using i32
.
impl<const D: usize> Vector<i32, D>
§Methods for vectors represented using i32
.
Sourcepub const fn c_normalize_with(self, magnitude: i32) -> Self
Available on crate feature _int_i32
only.
pub const fn c_normalize_with(self, magnitude: i32) -> Self
_int_i32
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> i32 ⓘ
Available on crate feature _int_i32
only.
pub const fn c_magnitude_sq(self) -> i32 ⓘ
_int_i32
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_i32
only.
pub const fn c_add(self, other: Self) -> Self
_int_i32
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_i32
only.
pub const fn c_sub(self, other: Self) -> Self
_int_i32
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> i32 ⓘ
Available on crate feature _int_i32
only.
pub const fn c_dot(self, other: Self) -> i32 ⓘ
_int_i32
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: i32) -> Self
Available on crate feature _int_i32
only.
pub const fn c_scalar_mul(self, scalar: i32) -> Self
_int_i32
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: i32) -> Self
Available on crate feature _int_i32
only.
pub const fn c_scalar_div(self, scalar: i32) -> Self
_int_i32
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<i32, 3>
§Methods for 3d vectors represented using i32
.
impl Vector<i32, 3>
§Methods for 3d vectors represented using i32
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<i32, D>
§Methods for vectors represented using i32
, signed.
impl<const D: usize> Vector<i32, D>
§Methods for vectors represented using i32
, signed.
Sourcepub const NEG_ONE: Self
Available on crate feature _int_i32
only.
pub const NEG_ONE: Self
_int_i32
only.A Vector
with all negative ones.
Sourcepub const fn c_magnitude_floor(self) -> i32 ⓘ
Available on crate feature _int_i32
only.
pub const fn c_magnitude_floor(self) -> i32 ⓘ
_int_i32
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
§Features
This will only be const if the “_cmp_i32” feature is enabled.
Sourcepub const fn c_magnitude_ceil(self) -> i32 ⓘ
Available on crate feature _int_i32
only.
pub const fn c_magnitude_ceil(self) -> i32 ⓘ
_int_i32
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
§Features
This will only be const if the “_cmp_i32” feature is enabled.
Sourcepub const fn c_magnitude_round(self) -> i32 ⓘ
Available on crate feature _int_i32
only.
pub const fn c_magnitude_round(self) -> i32 ⓘ
_int_i32
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a i128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<i64, D>
§Methods for vectors represented using i64
.
impl<const D: usize> Vector<i64, D>
§Methods for vectors represented using i64
.
Sourcepub const fn c_normalize_with(self, magnitude: i64) -> Self
Available on crate feature _int_i64
only.
pub const fn c_normalize_with(self, magnitude: i64) -> Self
_int_i64
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> i64 ⓘ
Available on crate feature _int_i64
only.
pub const fn c_magnitude_sq(self) -> i64 ⓘ
_int_i64
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_i64
only.
pub const fn c_add(self, other: Self) -> Self
_int_i64
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_i64
only.
pub const fn c_sub(self, other: Self) -> Self
_int_i64
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> i64 ⓘ
Available on crate feature _int_i64
only.
pub const fn c_dot(self, other: Self) -> i64 ⓘ
_int_i64
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: i64) -> Self
Available on crate feature _int_i64
only.
pub const fn c_scalar_mul(self, scalar: i64) -> Self
_int_i64
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: i64) -> Self
Available on crate feature _int_i64
only.
pub const fn c_scalar_div(self, scalar: i64) -> Self
_int_i64
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<i64, 3>
§Methods for 3d vectors represented using i64
.
impl Vector<i64, 3>
§Methods for 3d vectors represented using i64
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<i64, D>
§Methods for vectors represented using i64
, signed.
impl<const D: usize> Vector<i64, D>
§Methods for vectors represented using i64
, signed.
Sourcepub const NEG_ONE: Self
Available on crate feature _int_i64
only.
pub const NEG_ONE: Self
_int_i64
only.A Vector
with all negative ones.
Sourcepub const fn c_magnitude_floor(self) -> i64 ⓘ
Available on crate feature _int_i64
only.
pub const fn c_magnitude_floor(self) -> i64 ⓘ
_int_i64
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
§Features
This will only be const if the “_cmp_i64” feature is enabled.
Sourcepub const fn c_magnitude_ceil(self) -> i64 ⓘ
Available on crate feature _int_i64
only.
pub const fn c_magnitude_ceil(self) -> i64 ⓘ
_int_i64
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
§Features
This will only be const if the “_cmp_i64” feature is enabled.
Sourcepub const fn c_magnitude_round(self) -> i64 ⓘ
Available on crate feature _int_i64
only.
pub const fn c_magnitude_round(self) -> i64 ⓘ
_int_i64
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a i128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<i128, D>
§Methods for vectors represented using i128
.
impl<const D: usize> Vector<i128, D>
§Methods for vectors represented using i128
.
Sourcepub const fn c_normalize_with(self, magnitude: i128) -> Self
Available on crate feature _int_i128
only.
pub const fn c_normalize_with(self, magnitude: i128) -> Self
_int_i128
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> i128 ⓘ
Available on crate feature _int_i128
only.
pub const fn c_magnitude_sq(self) -> i128 ⓘ
_int_i128
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_i128
only.
pub const fn c_add(self, other: Self) -> Self
_int_i128
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_i128
only.
pub const fn c_sub(self, other: Self) -> Self
_int_i128
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> i128 ⓘ
Available on crate feature _int_i128
only.
pub const fn c_dot(self, other: Self) -> i128 ⓘ
_int_i128
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: i128) -> Self
Available on crate feature _int_i128
only.
pub const fn c_scalar_mul(self, scalar: i128) -> Self
_int_i128
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: i128) -> Self
Available on crate feature _int_i128
only.
pub const fn c_scalar_div(self, scalar: i128) -> Self
_int_i128
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<i128, 3>
§Methods for 3d vectors represented using i128
.
impl Vector<i128, 3>
§Methods for 3d vectors represented using i128
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<i128, D>
§Methods for vectors represented using i128
, signed.
impl<const D: usize> Vector<i128, D>
§Methods for vectors represented using i128
, signed.
Sourcepub const NEG_ONE: Self
Available on crate feature _int_i128
only.
pub const NEG_ONE: Self
_int_i128
only.A Vector
with all negative ones.
Sourcepub const fn c_magnitude_floor(self) -> i128 ⓘ
Available on crate feature _int_i128
only.
pub const fn c_magnitude_floor(self) -> i128 ⓘ
_int_i128
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
§Features
This will only be const if the “_cmp_i128” feature is enabled.
Sourcepub const fn c_magnitude_ceil(self) -> i128 ⓘ
Available on crate feature _int_i128
only.
pub const fn c_magnitude_ceil(self) -> i128 ⓘ
_int_i128
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
§Features
This will only be const if the “_cmp_i128” feature is enabled.
Sourcepub const fn c_magnitude_round(self) -> i128 ⓘ
Available on crate feature _int_i128
only.
pub const fn c_magnitude_round(self) -> i128 ⓘ
_int_i128
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a i128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<isize, D>
§Methods for vectors represented using isize
.
impl<const D: usize> Vector<isize, D>
§Methods for vectors represented using isize
.
Sourcepub const fn c_normalize_with(self, magnitude: isize) -> Self
Available on crate feature _int_isize
only.
pub const fn c_normalize_with(self, magnitude: isize) -> Self
_int_isize
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> isize ⓘ
Available on crate feature _int_isize
only.
pub const fn c_magnitude_sq(self) -> isize ⓘ
_int_isize
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_isize
only.
pub const fn c_add(self, other: Self) -> Self
_int_isize
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_isize
only.
pub const fn c_sub(self, other: Self) -> Self
_int_isize
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> isize ⓘ
Available on crate feature _int_isize
only.
pub const fn c_dot(self, other: Self) -> isize ⓘ
_int_isize
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: isize) -> Self
Available on crate feature _int_isize
only.
pub const fn c_scalar_mul(self, scalar: isize) -> Self
_int_isize
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: isize) -> Self
Available on crate feature _int_isize
only.
pub const fn c_scalar_div(self, scalar: isize) -> Self
_int_isize
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<isize, 3>
§Methods for 3d vectors represented using isize
.
impl Vector<isize, 3>
§Methods for 3d vectors represented using isize
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<isize, D>
§Methods for vectors represented using isize
, signed.
impl<const D: usize> Vector<isize, D>
§Methods for vectors represented using isize
, signed.
Sourcepub const NEG_ONE: Self
Available on crate feature _int_isize
only.
pub const NEG_ONE: Self
_int_isize
only.A Vector
with all negative ones.
Sourcepub const fn c_magnitude_floor(self) -> isize ⓘ
Available on crate feature _int_isize
only.
pub const fn c_magnitude_floor(self) -> isize ⓘ
_int_isize
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
§Features
This will only be const if the “_cmp_isize” feature is enabled.
Sourcepub const fn c_magnitude_ceil(self) -> isize ⓘ
Available on crate feature _int_isize
only.
pub const fn c_magnitude_ceil(self) -> isize ⓘ
_int_isize
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
§Features
This will only be const if the “_cmp_isize” feature is enabled.
Sourcepub const fn c_magnitude_round(self) -> isize ⓘ
Available on crate feature _int_isize
only.
pub const fn c_magnitude_round(self) -> isize ⓘ
_int_isize
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a i128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<u8, D>
§Methods for vectors represented using u8
.
impl<const D: usize> Vector<u8, D>
§Methods for vectors represented using u8
.
Sourcepub const fn c_normalize_with(self, magnitude: u8) -> Self
Available on crate feature _int_u8
only.
pub const fn c_normalize_with(self, magnitude: u8) -> Self
_int_u8
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> u8 ⓘ
Available on crate feature _int_u8
only.
pub const fn c_magnitude_sq(self) -> u8 ⓘ
_int_u8
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_u8
only.
pub const fn c_add(self, other: Self) -> Self
_int_u8
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_u8
only.
pub const fn c_sub(self, other: Self) -> Self
_int_u8
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> u8 ⓘ
Available on crate feature _int_u8
only.
pub const fn c_dot(self, other: Self) -> u8 ⓘ
_int_u8
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: u8) -> Self
Available on crate feature _int_u8
only.
pub const fn c_scalar_mul(self, scalar: u8) -> Self
_int_u8
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: u8) -> Self
Available on crate feature _int_u8
only.
pub const fn c_scalar_div(self, scalar: u8) -> Self
_int_u8
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<u8, 3>
§Methods for 3d vectors represented using u8
.
impl Vector<u8, 3>
§Methods for 3d vectors represented using u8
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<u8, D>
§Methods for vectors represented using u8
, unsigned.
impl<const D: usize> Vector<u8, D>
§Methods for vectors represented using u8
, unsigned.
Sourcepub const fn c_magnitude_floor(self) -> u8 ⓘ
Available on crate feature _int_u8
only.
pub const fn c_magnitude_floor(self) -> u8 ⓘ
_int_u8
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
§Features
This will only be const if the “_cmp_u8” feature is enabled.
Sourcepub const fn c_magnitude_ceil(self) -> u8 ⓘ
Available on crate feature _int_u8
only.
pub const fn c_magnitude_ceil(self) -> u8 ⓘ
_int_u8
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
§Features
This will only be const if the “_cmp_u8” feature is enabled.
Sourcepub const fn c_magnitude_round(self) -> u8 ⓘ
Available on crate feature _int_u8
only.
pub const fn c_magnitude_round(self) -> u8 ⓘ
_int_u8
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a u128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<u16, D>
§Methods for vectors represented using u16
.
impl<const D: usize> Vector<u16, D>
§Methods for vectors represented using u16
.
Sourcepub const fn c_normalize_with(self, magnitude: u16) -> Self
Available on crate feature _int_u16
only.
pub const fn c_normalize_with(self, magnitude: u16) -> Self
_int_u16
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> u16 ⓘ
Available on crate feature _int_u16
only.
pub const fn c_magnitude_sq(self) -> u16 ⓘ
_int_u16
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_u16
only.
pub const fn c_add(self, other: Self) -> Self
_int_u16
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_u16
only.
pub const fn c_sub(self, other: Self) -> Self
_int_u16
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> u16 ⓘ
Available on crate feature _int_u16
only.
pub const fn c_dot(self, other: Self) -> u16 ⓘ
_int_u16
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: u16) -> Self
Available on crate feature _int_u16
only.
pub const fn c_scalar_mul(self, scalar: u16) -> Self
_int_u16
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: u16) -> Self
Available on crate feature _int_u16
only.
pub const fn c_scalar_div(self, scalar: u16) -> Self
_int_u16
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<u16, 3>
§Methods for 3d vectors represented using u16
.
impl Vector<u16, 3>
§Methods for 3d vectors represented using u16
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<u16, D>
§Methods for vectors represented using u16
, unsigned.
impl<const D: usize> Vector<u16, D>
§Methods for vectors represented using u16
, unsigned.
Sourcepub const fn c_magnitude_floor(self) -> u16 ⓘ
Available on crate feature _int_u16
only.
pub const fn c_magnitude_floor(self) -> u16 ⓘ
_int_u16
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
§Features
This will only be const if the “_cmp_u16” feature is enabled.
Sourcepub const fn c_magnitude_ceil(self) -> u16 ⓘ
Available on crate feature _int_u16
only.
pub const fn c_magnitude_ceil(self) -> u16 ⓘ
_int_u16
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
§Features
This will only be const if the “_cmp_u16” feature is enabled.
Sourcepub const fn c_magnitude_round(self) -> u16 ⓘ
Available on crate feature _int_u16
only.
pub const fn c_magnitude_round(self) -> u16 ⓘ
_int_u16
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a u128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<u32, D>
§Methods for vectors represented using u32
.
impl<const D: usize> Vector<u32, D>
§Methods for vectors represented using u32
.
Sourcepub const fn c_normalize_with(self, magnitude: u32) -> Self
Available on crate feature _int_u32
only.
pub const fn c_normalize_with(self, magnitude: u32) -> Self
_int_u32
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> u32 ⓘ
Available on crate feature _int_u32
only.
pub const fn c_magnitude_sq(self) -> u32 ⓘ
_int_u32
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_u32
only.
pub const fn c_add(self, other: Self) -> Self
_int_u32
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_u32
only.
pub const fn c_sub(self, other: Self) -> Self
_int_u32
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> u32 ⓘ
Available on crate feature _int_u32
only.
pub const fn c_dot(self, other: Self) -> u32 ⓘ
_int_u32
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: u32) -> Self
Available on crate feature _int_u32
only.
pub const fn c_scalar_mul(self, scalar: u32) -> Self
_int_u32
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: u32) -> Self
Available on crate feature _int_u32
only.
pub const fn c_scalar_div(self, scalar: u32) -> Self
_int_u32
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<u32, 3>
§Methods for 3d vectors represented using u32
.
impl Vector<u32, 3>
§Methods for 3d vectors represented using u32
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<u32, D>
§Methods for vectors represented using u32
, unsigned.
impl<const D: usize> Vector<u32, D>
§Methods for vectors represented using u32
, unsigned.
Sourcepub const fn c_magnitude_floor(self) -> u32 ⓘ
Available on crate feature _int_u32
only.
pub const fn c_magnitude_floor(self) -> u32 ⓘ
_int_u32
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
§Features
This will only be const if the “_cmp_u32” feature is enabled.
Sourcepub const fn c_magnitude_ceil(self) -> u32 ⓘ
Available on crate feature _int_u32
only.
pub const fn c_magnitude_ceil(self) -> u32 ⓘ
_int_u32
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
§Features
This will only be const if the “_cmp_u32” feature is enabled.
Sourcepub const fn c_magnitude_round(self) -> u32 ⓘ
Available on crate feature _int_u32
only.
pub const fn c_magnitude_round(self) -> u32 ⓘ
_int_u32
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a u128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<u64, D>
§Methods for vectors represented using u64
.
impl<const D: usize> Vector<u64, D>
§Methods for vectors represented using u64
.
Sourcepub const fn c_normalize_with(self, magnitude: u64) -> Self
Available on crate feature _int_u64
only.
pub const fn c_normalize_with(self, magnitude: u64) -> Self
_int_u64
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> u64 ⓘ
Available on crate feature _int_u64
only.
pub const fn c_magnitude_sq(self) -> u64 ⓘ
_int_u64
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_u64
only.
pub const fn c_add(self, other: Self) -> Self
_int_u64
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_u64
only.
pub const fn c_sub(self, other: Self) -> Self
_int_u64
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> u64 ⓘ
Available on crate feature _int_u64
only.
pub const fn c_dot(self, other: Self) -> u64 ⓘ
_int_u64
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: u64) -> Self
Available on crate feature _int_u64
only.
pub const fn c_scalar_mul(self, scalar: u64) -> Self
_int_u64
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: u64) -> Self
Available on crate feature _int_u64
only.
pub const fn c_scalar_div(self, scalar: u64) -> Self
_int_u64
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<u64, 3>
§Methods for 3d vectors represented using u64
.
impl Vector<u64, 3>
§Methods for 3d vectors represented using u64
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<u64, D>
§Methods for vectors represented using u64
, unsigned.
impl<const D: usize> Vector<u64, D>
§Methods for vectors represented using u64
, unsigned.
Sourcepub const fn c_magnitude_floor(self) -> u64 ⓘ
Available on crate feature _int_u64
only.
pub const fn c_magnitude_floor(self) -> u64 ⓘ
_int_u64
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
§Features
This will only be const if the “_cmp_u64” feature is enabled.
Sourcepub const fn c_magnitude_ceil(self) -> u64 ⓘ
Available on crate feature _int_u64
only.
pub const fn c_magnitude_ceil(self) -> u64 ⓘ
_int_u64
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
§Features
This will only be const if the “_cmp_u64” feature is enabled.
Sourcepub const fn c_magnitude_round(self) -> u64 ⓘ
Available on crate feature _int_u64
only.
pub const fn c_magnitude_round(self) -> u64 ⓘ
_int_u64
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a u128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<u128, D>
§Methods for vectors represented using u128
.
impl<const D: usize> Vector<u128, D>
§Methods for vectors represented using u128
.
Sourcepub const fn c_normalize_with(self, magnitude: u128) -> Self
Available on crate feature _int_u128
only.
pub const fn c_normalize_with(self, magnitude: u128) -> Self
_int_u128
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> u128 ⓘ
Available on crate feature _int_u128
only.
pub const fn c_magnitude_sq(self) -> u128 ⓘ
_int_u128
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_u128
only.
pub const fn c_add(self, other: Self) -> Self
_int_u128
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_u128
only.
pub const fn c_sub(self, other: Self) -> Self
_int_u128
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> u128 ⓘ
Available on crate feature _int_u128
only.
pub const fn c_dot(self, other: Self) -> u128 ⓘ
_int_u128
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: u128) -> Self
Available on crate feature _int_u128
only.
pub const fn c_scalar_mul(self, scalar: u128) -> Self
_int_u128
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: u128) -> Self
Available on crate feature _int_u128
only.
pub const fn c_scalar_div(self, scalar: u128) -> Self
_int_u128
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<u128, 3>
§Methods for 3d vectors represented using u128
.
impl Vector<u128, 3>
§Methods for 3d vectors represented using u128
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<u128, D>
§Methods for vectors represented using u128
, unsigned.
impl<const D: usize> Vector<u128, D>
§Methods for vectors represented using u128
, unsigned.
Sourcepub const fn c_magnitude_floor(self) -> u128 ⓘ
Available on crate feature _int_u128
only.
pub const fn c_magnitude_floor(self) -> u128 ⓘ
_int_u128
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
§Features
This will only be const if the “_cmp_u128” feature is enabled.
Sourcepub const fn c_magnitude_ceil(self) -> u128 ⓘ
Available on crate feature _int_u128
only.
pub const fn c_magnitude_ceil(self) -> u128 ⓘ
_int_u128
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
§Features
This will only be const if the “_cmp_u128” feature is enabled.
Sourcepub const fn c_magnitude_round(self) -> u128 ⓘ
Available on crate feature _int_u128
only.
pub const fn c_magnitude_round(self) -> u128 ⓘ
_int_u128
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a u128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<usize, D>
§Methods for vectors represented using usize
.
impl<const D: usize> Vector<usize, D>
§Methods for vectors represented using usize
.
Sourcepub const fn c_normalize_with(self, magnitude: usize) -> Self
Available on crate feature _int_usize
only.
pub const fn c_normalize_with(self, magnitude: usize) -> Self
_int_usize
only.Returns the normalized vector, using the given vector magnitude
.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub const fn c_magnitude_sq(self) -> usize ⓘ
Available on crate feature _int_usize
only.
pub const fn c_magnitude_sq(self) -> usize ⓘ
_int_usize
only.Calculates the magnitude of the vector (squared).
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub const fn c_add(self, other: Self) -> Self
Available on crate feature _int_usize
only.
pub const fn c_add(self, other: Self) -> Self
_int_usize
only.Adds two vectors together, in compile-time.
Sourcepub const fn c_sub(self, other: Self) -> Self
Available on crate feature _int_usize
only.
pub const fn c_sub(self, other: Self) -> Self
_int_usize
only.Subtracts another vector from this vector, in compile-time.
Sourcepub const fn c_dot(self, other: Self) -> usize ⓘ
Available on crate feature _int_usize
only.
pub const fn c_dot(self, other: Self) -> usize ⓘ
_int_usize
only.Computes the dot product of two vectors, in compile-time.
Sourcepub const fn c_scalar_mul(self, scalar: usize) -> Self
Available on crate feature _int_usize
only.
pub const fn c_scalar_mul(self, scalar: usize) -> Self
_int_usize
only.Multiplies each element of the vector by a scalar, in compile-time.
Sourcepub const fn c_scalar_div(self, scalar: usize) -> Self
Available on crate feature _int_usize
only.
pub const fn c_scalar_div(self, scalar: usize) -> Self
_int_usize
only.Divides each element of the vector by a scalar, in compile-time.
Source§impl Vector<usize, 3>
§Methods for 3d vectors represented using usize
.
impl Vector<usize, 3>
§Methods for 3d vectors represented using usize
.
Sourcepub const fn c_cross(self, other: Self) -> Self
pub const fn c_cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<usize, D>
§Methods for vectors represented using usize
, unsigned.
impl<const D: usize> Vector<usize, D>
§Methods for vectors represented using usize
, unsigned.
Sourcepub const fn c_magnitude_floor(self) -> usize ⓘ
Available on crate feature _int_usize
only.
pub const fn c_magnitude_floor(self) -> usize ⓘ
_int_usize
only.Calculates the floored magnitude of the vector.
It could underestimate the true magnitude.
Sourcepub const fn c_magnitude_ceil(self) -> usize ⓘ
Available on crate feature _int_usize
only.
pub const fn c_magnitude_ceil(self) -> usize ⓘ
_int_usize
only.Calculates the ceiled magnitude of the vector.
It could overestimate the true magnitude.
Sourcepub const fn c_magnitude_round(self) -> usize ⓘ
Available on crate feature _int_usize
only.
pub const fn c_magnitude_round(self) -> usize ⓘ
_int_usize
only.Calculates the rounded magnitude of the vector.
§Panics
Can panic if we reach a u128
value close to its maximum during operations.
Source§impl<const D: usize> Vector<f32, D>
§Methods for vectors represented using f32
.
impl<const D: usize> Vector<f32, D>
§Methods for vectors represented using f32
.
Sourcepub const NEG_ONE: Self
Available on crate feature _float_f32
only.
pub const NEG_ONE: Self
_float_f32
only.A Vector
with all negative ones.
Sourcepub fn normalize(&self) -> Self
Available on crate feature _float_f32
only.
pub fn normalize(&self) -> Self
_float_f32
only.Returns the normalized vector, as a unit vector.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub fn magnitude_sq(self) -> f32 ⓘ
Available on crate feature _float_f32
only.
pub fn magnitude_sq(self) -> f32 ⓘ
_float_f32
only.Calculates the squared magnitude of the vector.
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub fn add(self, other: Self) -> Self
Available on crate feature _float_f32
only.
pub fn add(self, other: Self) -> Self
_float_f32
only.Adds two vectors together.
Sourcepub fn sub(self, other: Self) -> Self
Available on crate feature _float_f32
only.
pub fn sub(self, other: Self) -> Self
_float_f32
only.Subtracts another vector from this vector.
Sourcepub fn dot(self, other: Self) -> f32 ⓘ
Available on crate feature _float_f32
only.
pub fn dot(self, other: Self) -> f32 ⓘ
_float_f32
only.Computes the dot product of two vectors.
That is the magnitude of one vector in the direction of another.
Also known as the inner produc or the scalar product.
§Formula
$$ \large \vec{a}\cdot\vec{b} = \begin{bmatrix} a_0 \cr … \cr a_n \end{bmatrix} \cdot \begin{bmatrix} b_0 \cr … \cr b_n \end{bmatrix} = a_0 b_0 + … + a_n b_n $$
Source§impl Vector<f32, 3>
§Methods for 3d vectors represented using f32
.
impl Vector<f32, 3>
§Methods for 3d vectors represented using f32
.
Sourcepub fn cross(self, other: Self) -> Self
pub fn cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Source§impl<const D: usize> Vector<f64, D>
§Methods for vectors represented using f64
.
impl<const D: usize> Vector<f64, D>
§Methods for vectors represented using f64
.
Sourcepub const NEG_ONE: Self
Available on crate feature _float_f64
only.
pub const NEG_ONE: Self
_float_f64
only.A Vector
with all negative ones.
Sourcepub fn normalize(&self) -> Self
Available on crate feature _float_f64
only.
pub fn normalize(&self) -> Self
_float_f64
only.Returns the normalized vector, as a unit vector.
$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$
Sourcepub fn magnitude_sq(self) -> f64 ⓘ
Available on crate feature _float_f64
only.
pub fn magnitude_sq(self) -> f64 ⓘ
_float_f64
only.Calculates the squared magnitude of the vector.
This is faster than calculating the magnitude, which is useful for comparisons.
§Formula
$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$
Sourcepub fn add(self, other: Self) -> Self
Available on crate feature _float_f64
only.
pub fn add(self, other: Self) -> Self
_float_f64
only.Adds two vectors together.
Sourcepub fn sub(self, other: Self) -> Self
Available on crate feature _float_f64
only.
pub fn sub(self, other: Self) -> Self
_float_f64
only.Subtracts another vector from this vector.
Sourcepub fn dot(self, other: Self) -> f64 ⓘ
Available on crate feature _float_f64
only.
pub fn dot(self, other: Self) -> f64 ⓘ
_float_f64
only.Computes the dot product of two vectors.
That is the magnitude of one vector in the direction of another.
Also known as the inner produc or the scalar product.
§Formula
$$ \large \vec{a}\cdot\vec{b} = \begin{bmatrix} a_0 \cr … \cr a_n \end{bmatrix} \cdot \begin{bmatrix} b_0 \cr … \cr b_n \end{bmatrix} = a_0 b_0 + … + a_n b_n $$
Source§impl Vector<f64, 3>
§Methods for 3d vectors represented using f64
.
impl Vector<f64, 3>
§Methods for 3d vectors represented using f64
.
Sourcepub fn cross(self, other: Self) -> Self
pub fn cross(self, other: Self) -> Self
Computes the cross product of two vectors.
That is the vector orthogonal to both vectors.
Also known as the exterior product or the vector product.
It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.
§Formula
$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$
Trait Implementations§
Source§impl<T: Clone + Add<Output = T>, const D: usize> AddAssign<&Vector<T, D>> for Vector<T, D>
impl<T: Clone + Add<Output = T>, const D: usize> AddAssign<&Vector<T, D>> for Vector<T, D>
Source§fn add_assign(&mut self, other: &Self)
fn add_assign(&mut self, other: &Self)
+=
operation. Read moreSource§impl<T: ConstDefault, const D: usize> ConstDefault for Vector<T, D>
impl<T: ConstDefault, const D: usize> ConstDefault for Vector<T, D>
Source§impl<T: Clone + Div<Output = T>, const D: usize> DivAssign<&T> for Vector<T, D>
impl<T: Clone + Div<Output = T>, const D: usize> DivAssign<&T> for Vector<T, D>
Source§fn div_assign(&mut self, scalar: &T)
fn div_assign(&mut self, scalar: &T)
/=
operation. Read moreSource§impl<T: Clone + Div<Output = T>, const D: usize> DivAssign<T> for Vector<T, D>
impl<T: Clone + Div<Output = T>, const D: usize> DivAssign<T> for Vector<T, D>
Source§fn div_assign(&mut self, scalar: T)
fn div_assign(&mut self, scalar: T)
/=
operation. Read moreSource§impl<T: Clone + Mul<Output = T>, const D: usize> MulAssign<&T> for Vector<T, D>
impl<T: Clone + Mul<Output = T>, const D: usize> MulAssign<&T> for Vector<T, D>
Source§fn mul_assign(&mut self, scalar: &T)
fn mul_assign(&mut self, scalar: &T)
*=
operation. Read moreSource§impl<T: Clone + Mul<Output = T>, const D: usize> MulAssign<T> for Vector<T, D>
impl<T: Clone + Mul<Output = T>, const D: usize> MulAssign<T> for Vector<T, D>
Source§fn mul_assign(&mut self, scalar: T)
fn mul_assign(&mut self, scalar: T)
*=
operation. Read moreSource§impl<T: Num, const D: usize> Num for Vector<T, D>
impl<T: Num, const D: usize> Num for Vector<T, D>
Source§fn num_from(value: Self::Inner) -> Result<Self>where
Self: Sized,
fn num_from(value: Self::Inner) -> Result<Self>where
Self: Sized,
Self
if given a valid value
.Source§fn num_from_ref(value: &Self::Inner) -> Result<Self>where
Self: Sized,
fn num_from_ref(value: &Self::Inner) -> Result<Self>where
Self: Sized,
Self
if given a valid &value
.Source§fn num_set_ref(&mut self, value: &Self::Inner) -> Result<()>
fn num_set_ref(&mut self, value: &Self::Inner) -> Result<()>
self
to the given valid &value
.Source§fn num_is_zero(&self) -> Result<bool>
fn num_is_zero(&self) -> Result<bool>
true
if self
is zero.Source§fn num_get_zero() -> Result<Self>where
Self: Sized,
fn num_get_zero() -> Result<Self>where
Self: Sized,
Source§fn num_set_zero(&mut self) -> Result<()>
fn num_set_zero(&mut self) -> Result<()>
self
to 0
.Source§fn num_is_one(&self) -> Result<bool>
fn num_is_one(&self) -> Result<bool>
true
if self
is one.Source§fn num_get_one() -> Result<Self>where
Self: Sized,
fn num_get_one() -> Result<Self>where
Self: Sized,
Source§fn num_set_one(&mut self) -> Result<()>
fn num_set_one(&mut self) -> Result<()>
Source§fn num_add(self, rhs: Self::Rhs) -> Result<Self::Out>where
Self: Sized,
fn num_add(self, rhs: Self::Rhs) -> Result<Self::Out>where
Self: Sized,
self + rhs
(addition).Source§fn num_ref_add(&self, rhs: &Self::Rhs) -> Result<Self::Out>
fn num_ref_add(&self, rhs: &Self::Rhs) -> Result<Self::Out>
num_add
but takes the arguments by reference.Source§fn num_ref_add_assign(&mut self, rhs: &Self::Rhs) -> Result<()>
fn num_ref_add_assign(&mut self, rhs: &Self::Rhs) -> Result<()>
&mut self += rhs;
(addition).Source§fn num_sub(self, rhs: Self::Rhs) -> Result<Self::Out>where
Self: Sized,
fn num_sub(self, rhs: Self::Rhs) -> Result<Self::Out>where
Self: Sized,
self - rhs
(subtraction).Source§fn num_ref_sub(&self, rhs: &Self::Rhs) -> Result<Self::Out>
fn num_ref_sub(&self, rhs: &Self::Rhs) -> Result<Self::Out>
num_sub
but takes the arguments by reference.Source§fn num_ref_sub_assign(&mut self, rhs: &Self::Rhs) -> Result<()>
fn num_ref_sub_assign(&mut self, rhs: &Self::Rhs) -> Result<()>
&mut self -= rhs;
(subtraction).Source§fn num_mul(self, rhs: Self::Rhs) -> Result<Self::Out>where
Self: Sized,
fn num_mul(self, rhs: Self::Rhs) -> Result<Self::Out>where
Self: Sized,
self * rhs
(multiplication).Source§fn num_ref_mul(&self, rhs: &Self::Rhs) -> Result<Self::Out>
fn num_ref_mul(&self, rhs: &Self::Rhs) -> Result<Self::Out>
num_mul
but takes the arguments by reference.Source§fn num_ref_mul_assign(&mut self, rhs: &Self::Rhs) -> Result<()>
fn num_ref_mul_assign(&mut self, rhs: &Self::Rhs) -> Result<()>
&mut self *= rhs;
(multiplication).Source§fn num_div(self, rhs: Self::Rhs) -> Result<Self::Out>where
Self: Sized,
fn num_div(self, rhs: Self::Rhs) -> Result<Self::Out>where
Self: Sized,
self / rhs
(division).Source§fn num_ref_div(&self, rhs: &Self::Rhs) -> Result<Self::Out>
fn num_ref_div(&self, rhs: &Self::Rhs) -> Result<Self::Out>
num_div
but takes the arguments by reference.Source§fn num_ref_div_assign(&mut self, rhs: &Self::Rhs) -> Result<()>
fn num_ref_div_assign(&mut self, rhs: &Self::Rhs) -> Result<()>
&mut self /= rhs;
(division).Source§fn num_rem(self, rhs: Self::Rhs) -> Result<Self::Out>where
Self: Sized,
fn num_rem(self, rhs: Self::Rhs) -> Result<Self::Out>where
Self: Sized,
self % rhs
(remainder).Source§fn num_ref_rem(&self, rhs: &Self::Rhs) -> Result<Self::Out>
fn num_ref_rem(&self, rhs: &Self::Rhs) -> Result<Self::Out>
num_rem
but takes the arguments by reference.Source§impl<T: Clone + Sub<Output = T>, const D: usize> SubAssign<&Vector<T, D>> for Vector<T, D>
impl<T: Clone + Sub<Output = T>, const D: usize> SubAssign<&Vector<T, D>> for Vector<T, D>
Source§fn sub_assign(&mut self, other: &Self)
fn sub_assign(&mut self, other: &Self)
-=
operation. Read moreSource§impl<T: Num + 'static, const D: usize> TryInto<Box<dyn NumVector<Rhs = Vector<T, D>, Out = Vector<T, D>, Scalar = T, Inner = [T; D]>>> for Vector<T, D>
Available on crate feature alloc
only.
impl<T: Num + 'static, const D: usize> TryInto<Box<dyn NumVector<Rhs = Vector<T, D>, Out = Vector<T, D>, Scalar = T, Inner = [T; D]>>> for Vector<T, D>
alloc
only.impl<T: Copy, const D: usize> Copy for Vector<T, D>
impl<T: Eq, const D: usize> Eq for Vector<T, D>
Auto Trait Implementations§
impl<T, const D: usize> Freeze for Vector<T, D>where
T: Freeze,
impl<T, const D: usize> RefUnwindSafe for Vector<T, D>where
T: RefUnwindSafe,
impl<T, const D: usize> Send for Vector<T, D>where
T: Send,
impl<T, const D: usize> Sync for Vector<T, D>where
T: Sync,
impl<T, const D: usize> Unpin for Vector<T, D>where
T: Unpin,
impl<T, const D: usize> UnwindSafe for Vector<T, D>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize ⓘ
fn byte_align(&self) -> usize ⓘ
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of_val(&self) -> usize ⓘ
fn mem_align_of_val(&self) -> usize ⓘ
Source§fn mem_size_of_val(&self) -> usize ⓘ
fn mem_size_of_val(&self) -> usize ⓘ
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.