Struct Vec4

Source
#[repr(C)]
pub struct Vec4<T>
where T: Scalar,
{ pub x: T, pub y: T, pub z: T, pub w: T, }
Expand description

4D generic vector Implemented for f32, f64, i32

Fields§

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

Implementations§

Source§

impl<T> Vec4<T>
where T: Scalar,

Source

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

Source

pub fn broadcast(a: T) -> Vec4<T>

Constructs a new Vec4 from a scalar value by copying that value to all members

§Examples
// V4f32 is a type alias for Vec4::<f32>
use imath::vec::V4f32;
let v = V4f32::broadcast(1.0);
assert!(v.x == 1.0 && v.y == 1.0 && v.z == 1.0 && v.w == 1.0)
Source

pub fn dot(self, v: Vec4<T>) -> T

Dot product

Source

pub fn equal_with_abs_error(self, v: Vec4<T>, e: T) -> bool
where T: PartialOrd,

Returns true if self and v are equal with error no greater than e

Source

pub fn equal_with_rel_error(self, v: Vec4<T>, e: T) -> bool
where T: Real,

Returns true if self and v are equal with error no greater than e

Source

pub fn length2(self) -> T

Calculate the squared length of the vector

Source§

impl Vec4<f32>

Source

pub fn length(self) -> f32

Length of the vector

Source

pub fn normalized(self) -> Vec4<f32>

Returns a normalized copy of this vector

Source§

impl Vec4<f64>

Source

pub fn length(self) -> f64

Length of the vector

Source

pub fn normalized(self) -> Vec4<f64>

Returns a normalized copy of this vector

Trait Implementations§

Source§

impl<T> Add<T> for Vec4<T>
where T: Scalar,

Addition by a T

Source§

type Output = Vec4<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Vec4<T>

Performs the + operation. Read more
Source§

impl Add<Vec4<f32>> for f32

Source§

type Output = Vec4<f32>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vec4<f32>) -> Vec4<f32>

Performs the + operation. Read more
Source§

impl Add<Vec4<f64>> for f64

Source§

type Output = Vec4<f64>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<Vec4<i32>> for i32

Source§

type Output = Vec4<i32>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vec4<i32>) -> Vec4<i32>

Performs the + operation. Read more
Source§

impl<T> Add for Vec4<T>
where T: Scalar,

Addition operator

Source§

type Output = Vec4<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Vec4<T>) -> Vec4<T>

Performs the + operation. Read more
Source§

impl<T> Bounded for Vec4<T>
where T: Scalar,

Source§

fn min_value() -> Vec4<T>

Returns the smallest finite number this type can represent
Source§

fn max_value() -> Vec4<T>

Returns the largest finite number this type can represent
Source§

impl<T> Clone for Vec4<T>
where T: Scalar + Clone,

Source§

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

Returns a copy 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 Vec4<T>
where T: Scalar + Debug,

Source§

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

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

impl<T> Default for Vec4<T>
where T: Scalar + Default,

Source§

fn default() -> Vec4<T>

Returns the “default value” for a type. Read more
Source§

impl<T> Display for Vec4<T>
where T: Scalar + Display,

Source§

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

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

impl<T> Div<T> for Vec4<T>
where T: Scalar,

Division by a T

Source§

type Output = Vec4<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Vec4<T>

Performs the / operation. Read more
Source§

impl Div<Vec4<f32>> for f32

Source§

type Output = Vec4<f32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Vec4<f32>) -> Vec4<f32>

Performs the / operation. Read more
Source§

impl Div<Vec4<f64>> for f64

Source§

type Output = Vec4<f64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Vec4<f64>) -> Vec4<f64>

Performs the / operation. Read more
Source§

impl Div<Vec4<i32>> for i32

Source§

type Output = Vec4<i32>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Vec4<i32>) -> Vec4<i32>

Performs the / operation. Read more
Source§

impl<T> Div for Vec4<T>
where T: Scalar,

Division operator

Source§

type Output = Vec4<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Vec4<T>) -> Vec4<T>

Performs the / operation. Read more
Source§

impl<T> From<Vec2<T>> for Vec4<T>
where T: Scalar,

Source§

fn from(v: Vec2<T>) -> Self

Converts a Vec2 to a Vec4, adding 0 z and w elements

Source§

impl<T> From<Vec3<T>> for Vec4<T>
where T: Scalar,

Source§

fn from(v: Vec3<T>) -> Self

Converts a Vec3 to a Vec4, adding a 0 w element

Source§

impl<T> From<Vec4<T>> for Vec2<T>
where T: Scalar,

Source§

fn from(v: Vec4<T>) -> Self

Converts a Vec4 to a Vec2, dropping the z element

Source§

impl<T> From<Vec4<T>> for Vec3<T>
where T: Scalar,

Source§

fn from(v: Vec4<T>) -> Self

Converts a Vec4 to a Vec3, dropping the w element

Source§

impl<T> Index<usize> for Vec4<T>
where T: Scalar,

Source§

type Output = T

The returned type after indexing.
Source§

fn index<'a>(&'a self, i: usize) -> &'a T

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<usize> for Vec4<T>
where T: Scalar,

Source§

fn index_mut<'a>(&'a mut self, i: usize) -> &'a mut T

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> Mul<T> for Vec4<T>
where T: Scalar,

Multiplication by a T

Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Vec4<T>

Performs the * operation. Read more
Source§

impl Mul<Vec4<f32>> for f32

Source§

type Output = Vec4<f32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<f32>) -> Vec4<f32>

Performs the * operation. Read more
Source§

impl Mul<Vec4<f64>> for f64

Source§

type Output = Vec4<f64>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<Vec4<i32>> for i32

Source§

type Output = Vec4<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<i32>) -> Vec4<i32>

Performs the * operation. Read more
Source§

impl<T> Mul for Vec4<T>
where T: Scalar,

Multiplication operator

Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec4<T>) -> Vec4<T>

Performs the * operation. Read more
Source§

impl<T> Neg for Vec4<T>
where T: Scalar,

Unary negation

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Vec4<T>

Performs the unary - operation. Read more
Source§

impl<T> One for Vec4<T>
where T: Scalar,

Source§

fn one() -> Vec4<T>
where T: Scalar,

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl<T> PartialEq for Vec4<T>
where T: Scalar + PartialEq,

Source§

fn eq(&self, other: &Vec4<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> PartialOrd for Vec4<T>
where T: Scalar + PartialOrd,

Source§

fn partial_cmp(&self, other: &Vec4<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> Sub<T> for Vec4<T>
where T: Scalar,

Subtraction by a T

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Vec4<T>

Performs the - operation. Read more
Source§

impl Sub<Vec4<f32>> for f32

Source§

type Output = Vec4<f32>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vec4<f32>) -> Vec4<f32>

Performs the - operation. Read more
Source§

impl Sub<Vec4<f64>> for f64

Source§

type Output = Vec4<f64>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<Vec4<i32>> for i32

Source§

type Output = Vec4<i32>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vec4<i32>) -> Vec4<i32>

Performs the - operation. Read more
Source§

impl<T> Sub for Vec4<T>
where T: Scalar,

Subtraction operator

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Vec4<T>) -> Vec4<T>

Performs the - operation. Read more
Source§

impl<T> Vector for Vec4<T>
where T: Scalar,

Source§

type Component = T

Source§

fn min(self, other: Vec4<T>) -> Vec4<T>

Source§

fn max(self, other: Vec4<T>) -> Vec4<T>

Source§

fn major_axis(self) -> usize

Source§

fn dot(a: Vec4<T>, b: Vec4<T>) -> T

Source§

fn length2(self) -> T

Source§

impl<T> Zero for Vec4<T>
where T: Scalar,

Source§

fn zero() -> Vec4<T>
where T: Scalar,

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool
where T: Scalar,

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl<T> Copy for Vec4<T>
where T: Scalar + Copy,

Source§

impl<T> Eq for Vec4<T>
where T: Scalar + Eq,

Source§

impl<T> StructuralPartialEq for Vec4<T>
where T: Scalar,

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Vec4<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> LowerBounded for T
where T: Bounded,

Source§

fn min_value() -> T

Returns the smallest finite number this type can represent
Source§

impl<T> Scalar for T
where T: Neg<Output = T> + PartialOrd + PartialEq + Add<Output = T> + Copy + Sub<Output = T> + Zero + Mul<Output = T> + One + Div<Output = T> + Bounded,

Source§

fn min(self, other: T) -> T

Source§

fn max(self, other: T) -> T

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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> UpperBounded for T
where T: Bounded,

Source§

fn max_value() -> T

Returns the largest finite number this type can represent