# [−]Struct lumol::types::Vector3D

A 3-dimensional vector type

A `Vector3D`

implement all the arithmetic operations:

let u = Vector3D::new(1.0, 2.0, 3.0); let v = Vector3D::new(4.0, -2.0, 1.0); // Indexing assert_eq!(u[0], 1.0); assert_eq!(u[1], 2.0); assert_eq!(u[2], 3.0); // Addition let w = u + v; assert_eq!(w, Vector3D::new(5.0, 0.0, 4.0)); // Subtraction let w = u - v; assert_eq!(w, Vector3D::new(-3.0, 4.0, 2.0)); // Negation let w = -u; assert_eq!(w, Vector3D::new(-1.0, -2.0, -3.0)); // Cross product let w = u ^ v; assert_eq!(w, Vector3D::new(8.0, 11.0, -10.0)); // Multiplication let w = 2.0 * u; assert_eq!(w, Vector3D::new(2.0, 4.0, 6.0)); let w = u * 3.0; assert_eq!(w, Vector3D::new(3.0, 6.0, 9.0)); // Division let w = u / 2.0; assert_eq!(w, Vector3D::new(0.5, 1.0, 1.5)); // Dot product let a = u * v; assert_eq!(a, 3.0);

## Methods

`impl Vector3D`

`pub fn new(x: f64, y: f64, z: f64) -> Vector3D`

Create a new `Vector3D`

with components `x`

, `y`

, `z`

# Examples

let vector = Vector3D::new(1.0, 0.0, -42.0); assert_eq!(vector[0], 1.0); assert_eq!(vector[1], 0.0); assert_eq!(vector[2], -42.0);

`pub fn zero() -> Vector3D`

Create a new `Vector3D`

with components `0`

, `0`

, `0`

# Examples

let vector = Vector3D::zero(); assert_eq!(vector[0], 0.0); assert_eq!(vector[1], 0.0); assert_eq!(vector[2], 0.0);

`pub fn norm2(&self) -> f64`

Return the squared euclidean norm of a `Vector3D`

# Examples

let vec = Vector3D::new(1.0, 0.0, -4.0); assert_eq!(vec.norm2(), 17.0);

`pub fn norm(&self) -> f64`

Return the euclidean norm of a `Vector3D`

# Examples

let vec = Vector3D::new(1.0, 0.0, -4.0); assert_eq!(vec.norm(), f64::sqrt(17.0));

`pub fn normalized(&self) -> Vector3D`

Normalize a `Vector3D`

.

# Examples

let vec = Vector3D::new(1.0, 0.0, -4.0); let n = vec.normalized(); assert_eq!(n.norm(), 1.0);

`pub fn tensorial(&self, other: &Vector3D) -> Matrix3`

Tensorial product between vectors. The tensorial product between the
vectors `a`

and `b`

creates a `Matrix3`

with component (i, j) equals to
`a[i] * b[j]`

.

# Examples

let a = Vector3D::new(1.0, 0.0, -4.0); let b = Vector3D::new(1.0, 2.0, 3.0); let matrix = Matrix3::new([ [1.0, 2.0, 3.0], [0.0, 0.0, 0.0], [-4.0, -8.0, -12.0] ]); assert_eq!(a.tensorial(&b), matrix);

`pub fn min(&self) -> f64`

Get the minimal value in this vector, using `std::f64::min`

for
comparison.

# Examples

let vector = Vector3D::new(1.0, 0.0, -4.0); assert_eq!(vector.min(), -4.0);

`pub fn max(&self) -> f64`

Get the maximal value in this vector, using `std::f64::max`

for
comparison.

# Examples

let vector = Vector3D::new(1.0, 0.0, -4.0); assert_eq!(vector.max(), 1.0);

## Trait Implementations

`impl<'a> Sub<Vector3D> for &'a Vector3D`

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`fn sub(self, other: Vector3D) -> Vector3D`

`impl<'a> Sub<&'a Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`fn sub(self, other: &'a Vector3D) -> Vector3D`

`impl<'a, 'b> Sub<&'a mut Vector3D> for &'b mut Vector3D`

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`fn sub(self, other: &'a mut Vector3D) -> Vector3D`

`impl<'a, 'b> Sub<&'a mut Vector3D> for &'b Vector3D`

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`fn sub(self, other: &'a mut Vector3D) -> Vector3D`

`impl<'a> Sub<Vector3D> for &'a mut Vector3D`

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`fn sub(self, other: Vector3D) -> Vector3D`

`impl<'a, 'b> Sub<&'a Vector3D> for &'b Vector3D`

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`fn sub(self, other: &'a Vector3D) -> Vector3D`

`impl Sub<Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`fn sub(self, other: Vector3D) -> Vector3D`

`impl<'a> Sub<&'a mut Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`fn sub(self, other: &'a mut Vector3D) -> Vector3D`

`impl<'a, 'b> Sub<&'a Vector3D> for &'b mut Vector3D`

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`fn sub(self, other: &'a Vector3D) -> Vector3D`

`impl Default for Vector3D`

`impl<'a, 'b> BitXor<&'a Vector3D> for &'b Vector3D`

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

`fn bitxor(self, other: &'a Vector3D) -> Vector3D`

`impl BitXor<Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

`fn bitxor(self, other: Vector3D) -> Vector3D`

`impl<'a, 'b> BitXor<&'a Vector3D> for &'b mut Vector3D`

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

`fn bitxor(self, other: &'a Vector3D) -> Vector3D`

`impl<'a> BitXor<Vector3D> for &'a Vector3D`

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

`fn bitxor(self, other: Vector3D) -> Vector3D`

`impl<'a, 'b> BitXor<&'a mut Vector3D> for &'b mut Vector3D`

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

`fn bitxor(self, other: &'a mut Vector3D) -> Vector3D`

`impl<'a> BitXor<&'a Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

`fn bitxor(self, other: &'a Vector3D) -> Vector3D`

`impl<'a, 'b> BitXor<&'a mut Vector3D> for &'b Vector3D`

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

`fn bitxor(self, other: &'a mut Vector3D) -> Vector3D`

`impl<'a> BitXor<Vector3D> for &'a mut Vector3D`

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

`fn bitxor(self, other: Vector3D) -> Vector3D`

`impl<'a> BitXor<&'a mut Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

`fn bitxor(self, other: &'a mut Vector3D) -> Vector3D`

`impl From<[f64; 3]> for Vector3D`

`impl<'a> AddAssign<Vector3D> for Vector3D`

`fn add_assign(&mut self, other: Vector3D)`

`impl<'a> AddAssign<&'a Vector3D> for Vector3D`

`fn add_assign(&mut self, other: &'a Vector3D)`

`impl<'a> AddAssign<&'a mut Vector3D> for Vector3D`

`fn add_assign(&mut self, other: &'a mut Vector3D)`

`impl<'a> MulAssign<f64> for Vector3D`

`fn mul_assign(&mut self, other: f64)`

`impl<'a> MulAssign<&'a f64> for Vector3D`

`fn mul_assign(&mut self, other: &'a f64)`

`impl<'a> MulAssign<&'a mut f64> for Vector3D`

`fn mul_assign(&mut self, other: &'a mut f64)`

`impl PartialOrd<Vector3D> for Vector3D`

`fn partial_cmp(&self, other: &Vector3D) -> Option<Ordering>`

`fn lt(&self, other: &Vector3D) -> bool`

`fn le(&self, other: &Vector3D) -> bool`

`fn gt(&self, other: &Vector3D) -> bool`

`fn ge(&self, other: &Vector3D) -> bool`

`impl<'a> Neg for &'a mut Vector3D`

`impl Neg for Vector3D`

`impl<'a> Neg for &'a Vector3D`

`impl<'a> Mul<f64> for &'a Vector3D`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: f64) -> Vector3D`

`impl Mul<Vector3D> for Vector3D`

`type Output = f64`

The resulting type after applying the `*`

operator.

`fn mul(self, other: Vector3D) -> f64`

`impl<'a, 'b> Mul<&'a Vector3D> for &'b Matrix3`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a Vector3D) -> Vector3D`

`impl<'a> Mul<f64> for &'a mut Vector3D`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: f64) -> Vector3D`

`impl<'a, 'b> Mul<&'a mut Vector3D> for &'b Matrix3`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a mut Vector3D) -> Vector3D`

`impl<'a> Mul<&'a Vector3D> for Vector3D`

`type Output = f64`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a Vector3D) -> f64`

`impl<'a> Mul<Vector3D> for &'a mut Vector3D`

`type Output = f64`

The resulting type after applying the `*`

operator.

`fn mul(self, other: Vector3D) -> f64`

`impl<'a, 'b> Mul<&'a mut Vector3D> for &'b Vector3D`

`type Output = f64`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a mut Vector3D) -> f64`

`impl<'a, 'b> Mul<&'a mut Vector3D> for &'b mut Matrix3`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a mut Vector3D) -> Vector3D`

`impl<'a> Mul<&'a Vector3D> for Matrix3`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a Vector3D) -> Vector3D`

`impl<'a> Mul<Vector3D> for &'a mut Matrix3`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: Vector3D) -> Vector3D`

`impl<'a, 'b> Mul<&'a mut Vector3D> for &'b mut Vector3D`

`type Output = f64`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a mut Vector3D) -> f64`

`impl Mul<Vector3D> for Matrix3`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: Vector3D) -> Vector3D`

`impl<'a, 'b> Mul<&'a Vector3D> for &'b Vector3D`

`type Output = f64`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a Vector3D) -> f64`

`impl<'a> Mul<Vector3D> for &'a Vector3D`

`type Output = f64`

The resulting type after applying the `*`

operator.

`fn mul(self, other: Vector3D) -> f64`

`impl Mul<f64> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: f64) -> Vector3D`

`impl<'a> Mul<&'a mut Vector3D> for Vector3D`

`type Output = f64`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a mut Vector3D) -> f64`

`impl<'a> Mul<Vector3D> for &'a Matrix3`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: Vector3D) -> Vector3D`

`impl<'a, 'b> Mul<&'a Vector3D> for &'b mut Vector3D`

`type Output = f64`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a Vector3D) -> f64`

`impl<'a, 'b> Mul<&'a Vector3D> for &'b mut Matrix3`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a Vector3D) -> Vector3D`

`impl<'a> Mul<&'a mut Vector3D> for Matrix3`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

`fn mul(self, other: &'a mut Vector3D) -> Vector3D`

`impl<'a> SubAssign<&'a Vector3D> for Vector3D`

`fn sub_assign(&mut self, other: &'a Vector3D)`

`impl<'a> SubAssign<Vector3D> for Vector3D`

`fn sub_assign(&mut self, other: Vector3D)`

`impl<'a> SubAssign<&'a mut Vector3D> for Vector3D`

`fn sub_assign(&mut self, other: &'a mut Vector3D)`

`impl Copy for Vector3D`

`impl Zero for Vector3D`

`impl Deref for Vector3D`

`type Target = [f64; 3]`

The resulting type after dereferencing.

`fn deref(&self) -> &<Vector3D as Deref>::Target`

`impl PartialEq<Vector3D> for Vector3D`

`impl DerefMut for Vector3D`

`impl<'a> DivAssign<&'a mut f64> for Vector3D`

`fn div_assign(&mut self, other: &'a mut f64)`

`impl<'a> DivAssign<f64> for Vector3D`

`fn div_assign(&mut self, other: f64)`

`impl<'a> DivAssign<&'a f64> for Vector3D`

`fn div_assign(&mut self, other: &'a f64)`

`impl Div<f64> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `/`

operator.

`fn div(self, other: f64) -> Vector3D`

`impl<'a> Div<f64> for &'a Vector3D`

`type Output = Vector3D`

The resulting type after applying the `/`

operator.

`fn div(self, other: f64) -> Vector3D`

`impl<'a> Div<f64> for &'a mut Vector3D`

`type Output = Vector3D`

The resulting type after applying the `/`

operator.

`fn div(self, other: f64) -> Vector3D`

`impl Clone for Vector3D`

`fn clone(&self) -> Vector3D`

`fn clone_from(&mut self, source: &Self)`

1.0.0[src]

Performs copy-assignment from `source`

. Read more

`impl<'a> Add<&'a Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

`fn add(self, other: &'a Vector3D) -> Vector3D`

`impl<'a> Add<Vector3D> for &'a Vector3D`

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

`fn add(self, other: Vector3D) -> Vector3D`

`impl<'a, 'b> Add<&'a Vector3D> for &'b mut Vector3D`

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

`fn add(self, other: &'a Vector3D) -> Vector3D`

`impl<'a, 'b> Add<&'a mut Vector3D> for &'b mut Vector3D`

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

`fn add(self, other: &'a mut Vector3D) -> Vector3D`

`impl Add<Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

`fn add(self, other: Vector3D) -> Vector3D`

`impl<'a> Add<Vector3D> for &'a mut Vector3D`

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

`fn add(self, other: Vector3D) -> Vector3D`

`impl<'a> Add<&'a mut Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

`fn add(self, other: &'a mut Vector3D) -> Vector3D`

`impl<'a, 'b> Add<&'a mut Vector3D> for &'b Vector3D`

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

`fn add(self, other: &'a mut Vector3D) -> Vector3D`

`impl<'a, 'b> Add<&'a Vector3D> for &'b Vector3D`

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

`fn add(self, other: &'a Vector3D) -> Vector3D`

`impl Debug for Vector3D`

## Auto Trait Implementations

## Blanket Implementations

`impl<T> From for T`

[src]

`impl<T, U> Into for T where`

U: From<T>,

[src]

U: From<T>,

`impl<T> ToOwned for T where`

T: Clone,

[src]

T: Clone,

`impl<T, U> TryFrom for T where`

T: From<U>,

[src]

T: From<U>,

`type Error = !`

`try_from`

)The type returned in the event of a conversion error.

`fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`

[src]

`impl<T> Borrow for T where`

T: ?Sized,

[src]

T: ?Sized,

`impl<T> BorrowMut for T where`

T: ?Sized,

[src]

T: ?Sized,

`fn borrow_mut(&mut self) -> &mut T`

[src]

`impl<T, U> TryInto for T where`

U: TryFrom<T>,

[src]

U: TryFrom<T>,

`type Error = <U as TryFrom<T>>::Error`

`try_from`

)The type returned in the event of a conversion error.

`fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`

[src]

`impl<T> Any for T where`

T: 'static + ?Sized,

[src]

T: 'static + ?Sized,