Skip to main content

Vector3

Struct Vector3 

Source
pub struct Vector3<T> {
    pub x: T,
    pub y: T,
    pub z: T,
}
Expand description

A 3-component vector.

Fields§

§x: T§y: T§z: T

Implementations§

Source§

impl<T: Default> Vector3<T>

Source

pub fn zeros() -> Self

Zero vector.

Source§

impl<T> Vector3<T>

Source

pub fn new(x: T, y: T, z: T) -> Self

Construct from components.

Source§

impl Vector3<f64>

Source

pub fn norm(&self) -> f64

Euclidean norm.

Source

pub fn normalize(&self) -> Self

Normalise to unit length. Returns zero vector if norm is near zero.

Source

pub fn dot(&self, rhs: &Self) -> f64

Dot product.

Source

pub fn cross(&self, rhs: &Self) -> Self

Cross product.

Source

pub fn outer(&self, rhs: &Self) -> Matrix3<f64>

Outer product (self * rhs^T), yielding a 3x3 matrix.

Source

pub fn transpose(&self) -> TransposedVector3

Return the 1x3 transpose as a TransposedVector3 for nalgebra-like centered * world_centered.transpose() patterns producing a Matrix3.

Source

pub fn scale_mut(&mut self, s: f64)

Scale in place (matches nalgebra’s scale_mut on vector views).

Trait Implementations§

Source§

impl Add for Vector3<f64>

Source§

type Output = Vector3<f64>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl Add<Vector3<f64>> for Point3<f64>

Point3 + Vector3 → Point3

Source§

type Output = Point3<f64>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vector3<f64>) -> Self

Performs the + operation. Read more
Source§

impl AddAssign for Vector3<f64>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl AddAssign<Vector3<f64>> for Point3<f64>

Point3 += Vector3

Source§

fn add_assign(&mut self, rhs: Vector3<f64>)

Performs the += operation. Read more
Source§

impl<T: Clone> Clone for Vector3<T>

Source§

fn clone(&self) -> Vector3<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Copy> Copy for Vector3<T>

Source§

impl<T: Debug> Debug for Vector3<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, T> Deserialize<'de> for Vector3<T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Div<f64> for Vector3<f64>

Source§

type Output = Vector3<f64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self

Performs the / operation. Read more
Source§

impl DivAssign<f64> for Vector3<f64>

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl From<Vector3<f64>> for Point3<f64>

Construct Point3 from Vector3 (via From trait).

Source§

fn from(v: Vector3<f64>) -> Self

Converts to this type from the input type.
Source§

impl Mul<TransposedVector3> for Vector3<f64>

Vector3 * TransposedVector3 → Matrix3 (outer product).

Source§

type Output = Matrix3<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: TransposedVector3) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Vector3<f64>> for &UnitQuaternion<f64>

&UnitQuaternion * Vector3

Source§

type Output = Vector3<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, v: Vector3<f64>) -> Vector3<f64>

Performs the * operation. Read more
Source§

impl Mul<Vector3<f64>> for Matrix3<f64>

Matrix3 * Vector3 → Vector3

Source§

type Output = Vector3<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector3<f64>) -> Vector3<f64>

Performs the * operation. Read more
Source§

impl Mul<Vector3<f64>> for UnitQuaternion<f64>

UnitQuaternion * Vector3 — rotate a vector.

Source§

type Output = Vector3<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, v: Vector3<f64>) -> Vector3<f64>

Performs the * operation. Read more
Source§

impl Mul<Vector3<f64>> for f64

Source§

type Output = Vector3<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vector3<f64>) -> Vector3<f64>

Performs the * operation. Read more
Source§

impl Mul<f64> for Vector3<f64>

Source§

type Output = Vector3<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self

Performs the * operation. Read more
Source§

impl MulAssign<f64> for Vector3<f64>

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl Neg for Vector3<f64>

Source§

type Output = Vector3<f64>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T: PartialEq> PartialEq for Vector3<T>

Source§

fn eq(&self, other: &Vector3<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for Vector3<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> StructuralPartialEq for Vector3<T>

Source§

impl Sub for Vector3<f64>

Source§

type Output = Vector3<f64>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl Sub<Vector3<f64>> for Point3<f64>

Point3 - Vector3 → Point3

Source§

type Output = Point3<f64>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vector3<f64>) -> Self

Performs the - operation. Read more
Source§

impl SubAssign for Vector3<f64>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Vector3<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Vector3<T>
where T: RefUnwindSafe,

§

impl<T> Send for Vector3<T>
where T: Send,

§

impl<T> Sync for Vector3<T>
where T: Sync,

§

impl<T> Unpin for Vector3<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Vector3<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Vector3<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

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

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.