Trait geo_nd::Vector[][src]

pub trait Vector<F: Float, const D: usize>: Clone + Copy + Debug + Display + Default + AsRef<[F; D]> + AsMut<[F; D]> + AsRef<[F]> + AsMut<[F]> + Index<usize, Output = F> + IndexMut<usize> + Neg<Output = Self> + Add<Self, Output = Self> + Add<F, Output = Self> + AddAssign<Self> + AddAssign<F> + Sub<Self, Output = Self> + Sub<F, Output = Self> + SubAssign<Self> + SubAssign<F> + Mul<Self, Output = Self> + Mul<F, Output = Self> + MulAssign<Self> + MulAssign<F> + Div<Self, Output = Self> + Div<F, Output = Self> + DivAssign<Self> + DivAssign<F> {
Show 13 methods fn from_array(data: [F; D]) -> Self;
fn zero() -> Self;
fn is_zero(&self) -> bool;
fn set_zero(&mut self);
fn reduce_sum(&self) -> F;
fn mix(&self, other: &Self, t: F) -> Self;
fn dot(&self, other: &Self) -> F; fn length_sq(&self) -> F { ... }
fn length(&self) -> F { ... }
fn distance_sq(&self, other: &Self) -> F { ... }
fn distance(&self, other: &Self) -> F { ... }
fn normalize(&mut self) { ... }
fn rotate_around(self, pivot: &Self, angle: F, c0: usize, c1: usize) -> Self { ... }
}
Expand description

The Vector trait describes an N-dimensional vector of Float type.

Such Vectors support basic vector arithmetic using addition and subtraction, and they provide component-wise multiplication and division, using the standard operators on two Vectors.

They also support basic arithmetic to all components of the Vector for addition, subtraction, multiplication and division by a scalar Float value type that they are comprised of. Hence a v:Vector<F> may be scaled by a s:F using v * s.

The Vector can be indexed only by a usize; that is individual components of the vector can be accessed, but ranges may not.

Required methods

Create a vector from an array of Float

Create a vector whose elements are all zero

Return true if the vector is all zeros

Set the vector to be all zeros

Sum all of the components of the vector

Create a linear combination of this Vector and another using parameter t from zero to one

Return the dot product of two vectors

Provided methods

Return the square of the length of the vector

Return the length of the vector

Return the square of the distance between this vector and another

Return the distance between this vector and another

Normalize the vector; if its length is close to zero, then set it to be zero

Rotate a vector within a plane around a pivot point by the specified angle

The plane of rotation is specified by providing two vector indices for the elements to adjust. For a 2D rotation then the values of c0 and c1 should be 0 and 1.

For a 3D rotation about the Z axis, they should be 0 and 1; for rotation about the Y axis they should be 2 and 0; and for rotation about the X axis they should be 1 and 2.

Implementors