Struct Vector4

Source
pub struct Vector4<T>(pub T, pub T, pub T, pub T);
Expand description

A 4D vector

Tuple Fields§

§0: T§1: T§2: T§3: T

Implementations§

Source§

impl<T> Vector4<T>
where T: Copy,

Source

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

Returns a new Vector4

§Arguments
  • x - The x direction scalar .0
  • y - The y direction scalar .1
  • z - The z direction scalar .2
  • w - The w direction scalar .3
Source

pub fn from_vector3(vec3: Vector3<T>, w: T) -> Self

Returns a new Vector4 created by adding a w value to a Vector3

§Arguments
  • vec3 - The 3D Vector that the w direction scaler is added onto
  • w - The w direction scalar .3
Source

pub fn empty(zero: T) -> Self

Source

pub fn normalize(&self, length: Option<T>) -> Vector4<T>
where T: Mul<T, Output = T> + Div<T, Output = T> + Add<T, Output = T> + F32Fmt,

Source

pub fn norm(&self) -> T
where T: Add<T, Output = T> + Mul<T, Output = T> + F32Fmt + Copy,

Returns the magnitude or length of the Vector4 denoted ||q||

Trait Implementations§

Source§

impl<T> Add<T> for Vector4<T>
where T: Add<T, Output = T> + Copy,

Source§

type Output = Vector4<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T> Add for Vector4<T>
where T: Add<T, Output = T> + Copy,

Source§

type Output = Vector4<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T: Clone> Clone for Vector4<T>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Vector4<T>
where T: Debug + Copy,

Source§

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

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

impl<T> Div<T> for Vector4<T>
where T: Div<T, Output = T> + Copy,

Source§

type Output = Vector4<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> Div for Vector4<T>
where T: Div<T, Output = T> + Copy,

Source§

type Output = Vector4<T>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<T> F32Fmt for Vector4<T>
where T: Mul<T, Output = T> + F32Fmt,

Source§

type F32Fmt = Vector4<<T as F32Fmt>::F32Fmt>

Source§

fn intoF32Fmt(self) -> Self::F32Fmt

Source§

fn fromF32Fmt(f32_fmt: Self::F32Fmt) -> Self

Source§

fn sqrt(self) -> Self

Source§

fn cbrt(self) -> Self

Source§

fn f32_const_mul(self, constant: f32) -> Self

Source§

fn sin_mul(self, mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn cos_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn tan_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn asin_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn acos_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn atan_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn atan2_mul(self, _other: Self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn sinh_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn cosh_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

fn tanh_mul(self, _mul_by: Self) -> Self
where Self: Mul<Self, Output = Self> + Sized,

Source§

impl<T> From<[T; 4]> for Vector4<T>
where T: Copy,

Source§

fn from(other: [T; 4]) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Quaternion<T>> for Vector4<T>
where T: Copy,

Source§

fn from(other: Quaternion<T>) -> Vector4<T>

Converts to this type from the input type.
Source§

impl<T> From<Vector4<T>> for [T; 4]

Source§

fn from(other: Vector4<T>) -> [T; 4]

Converts to this type from the input type.
Source§

impl<T> From<Vector4<T>> for Vector3<T>
where T: Copy,

Source§

fn from(other: Vector4<T>) -> Vector3<T>

Converts to this type from the input type.
Source§

impl<T> Mul<T> for Vector4<T>
where T: Mul<T, Output = T> + Copy,

Source§

type Output = Vector4<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T> Mul<Vector4<T>> for Matrix4<T>
where T: Add<T, Output = T> + Mul<T, Output = T> + Copy,

Source§

fn mul(self, rhs: Vector4<T>) -> Self::Output

Matrix4 * Vec3d = type Vec3d

§Examples
use feo_math::linear_algebra::vector4::Vector4;
use feo_math::linear_algebra::matrix4::Matrix4;
let mat = Matrix4::new(
    [1, 2, 3, 4],
    [3, 4, 1, 2],
    [4, 1, 2, 3],
    [2, 3, 4, 1]
);
let vec = Vector4::new(1, 4, 2, 3);
assert_eq!(mat * vec, Vector4::new(27, 27, 21, 25));
Source§

type Output = Vector4<T>

The resulting type after applying the * operator.
Source§

impl<T> Mul for Vector4<T>
where T: Mul<T, Output = T> + Copy,

Source§

type Output = Vector4<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T> Neg for Vector4<T>
where T: Neg<Output = T> + Copy,

Source§

type Output = Vector4<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T> One for Vector4<T>
where T: One,

Source§

const ONE: Self

Source§

impl<T: PartialEq> PartialEq for Vector4<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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> Rem<T> for Vector4<T>
where T: Rem<T, Output = T> + Copy,

Source§

type Output = Vector4<T>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> Self::Output

Performs the % operation. Read more
Source§

impl<T> Rem for Vector4<T>
where T: Rem<T, Output = T> + Copy,

Source§

fn rem(self, rhs: Self) -> Self::Output

Vector4 % Vector4 = Vector4

§Examples
use feo_math::linear_algebra::vector4::Vector4;
 
Source§

type Output = Vector4<T>

The resulting type after applying the % operator.
Source§

impl<T> SignOps for Vector4<T>

Source§

fn ptcopysign(self, _sign: Self) -> Self

Source§

fn ptsignum(self) -> i8

Source§

fn abs(self) -> Self

Source§

impl<T> Sub<T> for Vector4<T>
where T: Sub<T, Output = T> + Copy,

Source§

type Output = Vector4<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T> Sub for Vector4<T>
where T: Sub<T, Output = T> + Copy,

Source§

type Output = Vector4<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T> Two for Vector4<T>
where T: Two,

Source§

const TWO: Self

Source§

impl<T> Zero for Vector4<T>
where T: Zero,

Source§

const ZERO: Self

Source§

impl<T> Construct<T> for Vector4<T>
where T: Construct<T>,

Source§

impl<T: Copy> Copy for Vector4<T>

Source§

impl<T> SqMatrix<T, Vector4<T>> for Matrix4<T>
where T: Construct<T>,

Source§

impl<T> StructuralPartialEq for Vector4<T>

Source§

impl<T> Vector<T> for Vector4<T>
where T: Construct<T>,

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Vector4<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> 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> 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.
Source§

impl<T, A> Typed<T> for A
where T: Construct<A>,