# [−]Struct lumol::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);

## Implementations

`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);

## Methods from Deref<Target = [f64; 3]>

`pub fn as_slice(&self) -> &[T]`

[src]

`array_methods`

)Returns a slice containing the entire array. Equivalent to `&s[..]`

.

`pub fn as_mut_slice(&mut self) -> &mut [T]`

[src]

`array_methods`

)Returns a mutable slice containing the entire array. Equivalent to
`&mut s[..]`

.

## Trait Implementations

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

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

`pub 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.

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

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

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

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

`impl Add<Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `+`

operator.

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

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

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

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

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

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

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

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

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

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

`impl BitXor<Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `^`

operator.

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

`impl Clone for Vector3D`

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

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

1.0.0[src]

`impl Copy for Vector3D`

`impl Debug for Vector3D`

`impl Default for Vector3D`

`impl Deref for Vector3D`

`type Target = [f64; 3]`

The resulting type after dereferencing.

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

`impl DerefMut for Vector3D`

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

`type Output = Vector3D`

The resulting type after applying the `/`

operator.

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

`impl Div<f64> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `/`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `/`

operator.

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

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

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

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

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

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

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

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

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

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

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

`type Output = f64`

The resulting type after applying the `*`

operator.

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

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

`type Output = f64`

The resulting type after applying the `*`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

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

`type Output = f64`

The resulting type after applying the `*`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

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

`type Output = f64`

The resulting type after applying the `*`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

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

`type Output = f64`

The resulting type after applying the `*`

operator.

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

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

`type Output = f64`

The resulting type after applying the `*`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

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

`type Output = f64`

The resulting type after applying the `*`

operator.

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

`impl Mul<Vector3D> for Matrix3`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

`impl Mul<Vector3D> for Vector3D`

`type Output = f64`

The resulting type after applying the `*`

operator.

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

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

`type Output = f64`

The resulting type after applying the `*`

operator.

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

`impl Mul<f64> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `*`

operator.

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

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

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

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

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

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

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

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

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`pub fn neg(self) -> Vector3D`

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

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`pub fn neg(self) -> Vector3D`

`impl Neg for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`pub fn neg(self) -> Vector3D`

`impl PartialEq<Vector3D> for Vector3D`

`impl PartialOrd<Vector3D> for Vector3D`

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

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

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

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

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

`impl StructuralPartialEq for Vector3D`

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

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`pub 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.

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

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

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

`pub 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.

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

`impl Sub<Vector3D> for Vector3D`

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

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

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

`type Output = Vector3D`

The resulting type after applying the `-`

operator.

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

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

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

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

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

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

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

`impl Zero for Vector3D`

## Auto Trait Implementations

`impl RefUnwindSafe for Vector3D`

`impl Send for Vector3D`

`impl Sync for Vector3D`

`impl Unpin for Vector3D`

`impl UnwindSafe for Vector3D`

## Blanket Implementations

`impl<T> Any for T where`

T: 'static + ?Sized,

[src]

T: 'static + ?Sized,

`impl<T> Borrow<T> for T where`

T: ?Sized,

[src]

T: ?Sized,

`impl<T> BorrowMut<T> for T where`

T: ?Sized,

[src]

T: ?Sized,

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

[src]

`impl<T> From<T> for T`

[src]

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

U: From<T>,

[src]

U: From<T>,

`impl<T> Pointable for T`

`pub const `**ALIGN**: usize

**ALIGN**: usize

`type Init = T`

The type for initializers.

`pub unsafe fn init(init: <T as Pointable>::Init) -> usize`

`pub unsafe fn deref<'a>(ptr: usize) -> &'a T`

`pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T`

`pub unsafe fn drop(ptr: usize)`

`impl<T> ToOwned for T where`

T: Clone,

[src]

T: Clone,

`type Owned = T`

The resulting type after obtaining ownership.

`pub fn to_owned(&self) -> T`

[src]

`pub fn clone_into(&self, target: &mut T)`

[src]

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

U: Into<T>,

[src]

U: Into<T>,

`type Error = Infallible`

The type returned in the event of a conversion error.

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

[src]

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

U: TryFrom<T>,

[src]

U: TryFrom<T>,

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

The type returned in the event of a conversion error.

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

[src]

`impl<V, T> VZip<V> for T where`

V: MultiLane<T>,

V: MultiLane<T>,