[−][src]Type Definition const_linear::matrix::Vector
type Vector<T, const N: usize> = Matrix<T, { N }, 1>;
An N dimensional vector, represented as a matrix with dimensions N x 1.
Methods
impl<T: Scalar, const N: usize> Vector<T, { N }>
[src]
pub fn length(&self) -> f64
[src]
Returns the length of the vector as an f64
.
Examples
use const_linear::{vector, Vector}; let v = vector![1, 1, 1]; assert_eq!(v.length(), f64::sqrt(3.0));
pub fn length_f32(&self) -> f32
[src]
Returns the length of the vector as an f32
.
Examples
use const_linear::{vector, Vector}; let v = vector![1, 1, 1]; assert_eq!(v.length(), f64::sqrt(3.0));
pub fn normalize(self) -> VectorF64<{ N }>
[src]
Consumes and normalizes the vector, returning the
unit vector of f64
values in the same direction
as the original vector.
Examples
use const_linear::{vector, Vector}; let v = vector![1, 1, 1].normalize(); assert_eq!(v.length(), 1.0);
pub fn normalize_f32(self) -> VectorF32<{ N }>
[src]
Consumes and normalizes the vector, returning the
unit vector of f32
values in the same direction
as the original vector.
Examples
use const_linear::{ traits::Real, vector, Vector, }; let v = vector![1, 1, 1].normalize_f32(); // Relative equality is needed here, since // the value doesn't come out as *exactly* // 1.0f32. let epsilon = std::f32::EPSILON; let relative = 1.0E-7f32; assert!(v.length_f32().approx_eq(1.0f32, epsilon, relative));
pub fn dot(&self, rhs: &Self) -> T
[src]
impl<T: Scalar> Vector<T, { 3 }>
[src]
Trait Implementations
impl<T: Scalar, const N: usize> Add<T> for Vector<T, { N }>
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: T) -> Self::Output
[src]
impl<T: Scalar, const N: usize> Div<T> for Vector<T, { N }>
[src]
Note that this impl will do integer division if T
happens to be an integer. If you want a floating point
representation, call Matrix::into_f64
or
Matrix::into_f32
before dividing.
type Output = Vector<T, { N }>
The resulting type after applying the /
operator.