nalgebra::base

Type Alias OVector

Source
pub type OVector<T, D> = Matrix<T, D, U1, Owned<T, D, U1>>;
Expand description

An owned D-dimensional column vector.

Aliased Type§

struct OVector<T, D> {
    pub data: <DefaultAllocator as Allocator<D>>::Buffer<T>,
    /* private fields */
}

Fields§

§data: <DefaultAllocator as Allocator<D>>::Buffer<T>

The data storage that contains all the matrix components. Disappointed?

Well, if you came here to see how you can access the matrix components, you may be in luck: you can access the individual components of all vectors with compile-time dimensions <= 6 using field notation like this: vec.x, vec.y, vec.z, vec.w, vec.a, vec.b. Reference and assignation work too:

let mut vec = Vector3::new(1.0, 2.0, 3.0);
vec.x = 10.0;
vec.y += 30.0;
assert_eq!(vec.x, 10.0);
assert_eq!(vec.y + 100.0, 132.0);

Similarly, for matrices with compile-time dimensions <= 6, you can use field notation like this: mat.m11, mat.m42, etc. The first digit identifies the row to address and the second digit identifies the column to address. So mat.m13 identifies the component at the first row and third column (note that the count of rows and columns start at 1 instead of 0 here. This is so we match the mathematical notation).

For all matrices and vectors, independently from their size, individual components can be accessed and modified using indexing: vec[20], mat[(20, 19)]. Here the indexing starts at 0 as you would expect.

Implementations§

Source§

impl<T, R> OVector<T, R>

Source

pub fn ith(i: usize, val: T) -> Self

The column vector with val as its i-th component.

Source

pub fn ith_axis(i: usize) -> Unit<Self>

The column unit vector with T::one() as its i-th component.

Source

pub fn x() -> Self
where R::Typenum: Cmp<U0, Output = Greater>,

The column vector with a 1 as its first component, and zero elsewhere.

Source

pub fn y() -> Self
where R::Typenum: Cmp<U1, Output = Greater>,

The column vector with a 1 as its second component, and zero elsewhere.

Source

pub fn z() -> Self
where R::Typenum: Cmp<U2, Output = Greater>,

The column vector with a 1 as its third component, and zero elsewhere.

Source

pub fn w() -> Self
where R::Typenum: Cmp<U3, Output = Greater>,

The column vector with a 1 as its fourth component, and zero elsewhere.

Source

pub fn a() -> Self
where R::Typenum: Cmp<U4, Output = Greater>,

The column vector with a 1 as its fifth component, and zero elsewhere.

Source

pub fn b() -> Self
where R::Typenum: Cmp<U5, Output = Greater>,

The column vector with a 1 as its sixth component, and zero elsewhere.

Source

pub fn x_axis() -> Unit<Self>
where R::Typenum: Cmp<U0, Output = Greater>,

The unit column vector with a 1 as its first component, and zero elsewhere.

Source

pub fn y_axis() -> Unit<Self>
where R::Typenum: Cmp<U1, Output = Greater>,

The unit column vector with a 1 as its second component, and zero elsewhere.

Source

pub fn z_axis() -> Unit<Self>
where R::Typenum: Cmp<U2, Output = Greater>,

The unit column vector with a 1 as its third component, and zero elsewhere.

Source

pub fn w_axis() -> Unit<Self>
where R::Typenum: Cmp<U3, Output = Greater>,

The unit column vector with a 1 as its fourth component, and zero elsewhere.

Source

pub fn a_axis() -> Unit<Self>
where R::Typenum: Cmp<U4, Output = Greater>,

The unit column vector with a 1 as its fifth component, and zero elsewhere.

Source

pub fn b_axis() -> Unit<Self>
where R::Typenum: Cmp<U5, Output = Greater>,

The unit column vector with a 1 as its sixth component, and zero elsewhere.

Source§

impl<T: ComplexField, D: DimName> OVector<T, D>

§Basis and orthogonalization

Source

pub fn orthonormalize(vs: &mut [Self]) -> usize

Orthonormalizes the given family of vectors. The largest free family of vectors is moved at the beginning of the array and its size is returned. Vectors at an indices larger or equal to this length can be modified to an arbitrary value.

Source

pub fn orthonormal_subspace_basis<F>(vs: &[Self], f: F)
where F: FnMut(&Self) -> bool,

Applies the given closure to each element of the orthonormal basis of the subspace orthogonal to free family of vectors vs. If vs is not a free family, the result is unspecified.

Trait Implementations§

Source§

impl<T: Scalar + Zero + One, D> From<OPoint<T, D>> for OVector<T, DimNameSum<D, U1>>

Source§

fn from(t: OPoint<T, D>) -> Self

Converts to this type from the input type.