Struct euler::DVec4

source ·
#[repr(C)]
pub struct DVec4 { pub x: f64, pub y: f64, pub z: f64, pub w: f64, }
Expand description

Double-precision 4D vector.

Fields§

§x: f64§y: f64§z: f64§w: f64

Implementations§

source§

impl DVec4

source

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

Full constructor.

source

pub fn zero() -> Self

Zero constructor.

source

pub fn xy(self) -> DVec2

Returns the XY components of the vector.

Examples found in repository?
examples/unproject.rs (line 33)
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
fn unproject_double_precision(ndc: euler::Vec2) -> euler::DVec3 {
    let projection = dmat4!();
    let inverse_projection = projection.inverse();
    let eye = inverse_projection * dvec4!(dvec2!(ndc), -1, 1);
    let view = euler::DTrs::new(
        dvec3!(1, 0, -1),
        dquat!(1, 0, 0; f64::consts::PI / 2.0),
        dvec3!(1.0),
    )
    .matrix();
    let inverse_view = view.inverse();
    let world = inverse_view * dvec4!(eye.xy(), -1, 0);
    let ray = world.xyz().normalize();
    ray
}
source

pub fn xyz(self) -> DVec3

Returns the XYZ components of the vector.

Examples found in repository?
examples/unproject.rs (line 34)
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
fn unproject_double_precision(ndc: euler::Vec2) -> euler::DVec3 {
    let projection = dmat4!();
    let inverse_projection = projection.inverse();
    let eye = inverse_projection * dvec4!(dvec2!(ndc), -1, 1);
    let view = euler::DTrs::new(
        dvec3!(1, 0, -1),
        dquat!(1, 0, 0; f64::consts::PI / 2.0),
        dvec3!(1.0),
    )
    .matrix();
    let inverse_view = view.inverse();
    let world = inverse_view * dvec4!(eye.xy(), -1, 0);
    let ray = world.xyz().normalize();
    ray
}
source§

impl DVec4

source

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

Returns the dot product of two vectors.

source

pub fn length(self) -> f64

Returns the length (magnitude) of the vector.

source

pub fn squared_length(self) -> f64

Returns the squared length of the vector.

source

pub fn normalize(self) -> DVec4

Scales the vector to unit length.

Panics

Panics if the vector is zero.

Trait Implementations§

source§

impl Add<DVec4> for DVec4

§

type Output = DVec4

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl AddAssign<DVec4> for DVec4

source§

fn add_assign(&mut self, rhs: DVec4)

Performs the += operation. Read more
source§

impl ApproxEq for DVec4

§

type Epsilon = <Vector4<f64> as ApproxEq>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
source§

fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
source§

fn relative_ne( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of ApproxEq::relative_eq.
source§

fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of ApproxEq::ulps_eq.
source§

impl AsRef<[f64; 4]> for DVec4

source§

fn as_ref(&self) -> &[f64; 4]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for DVec4

source§

fn clone(&self) -> DVec4

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 Debug for DVec4

source§

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

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

impl Default for DVec4

source§

fn default() -> DVec4

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

impl Display for DVec4

source§

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

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

impl Div<f64> for DVec4

§

type Output = DVec4

The resulting type after applying the / operator.
source§

fn div(self, arg: f64) -> Self::Output

Performs the / operation. Read more
source§

impl DivAssign<f64> for DVec4

source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
source§

impl From<[f64; 4]> for DVec4

source§

fn from(array: [f64; 4]) -> Self

Converts to this type from the input type.
source§

impl<T: Into<DVec3>> From<(T, f64)> for DVec4

source§

fn from(arg: (T, f64)) -> Self

Converts to this type from the input type.
source§

impl<T: Into<DVec2>> From<(T, f64, f64)> for DVec4

source§

fn from(arg: (T, f64, f64)) -> Self

Converts to this type from the input type.
source§

impl From<DVec4> for Vec4

source§

fn from(arg: DVec4) -> Self

Converts to this type from the input type.
source§

impl From<Vec4> for DVec4

source§

fn from(arg: Vec4) -> Self

Converts to this type from the input type.
source§

impl From<f32> for DVec4

source§

fn from(arg: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for DVec4

source§

fn from(arg: f64) -> Self

Converts to this type from the input type.
source§

impl Into<[f64; 4]> for DVec4

source§

fn into(self) -> [f64; 4]

Converts this type into the (usually inferred) input type.
source§

impl<'a> Mul<DVec4> for &'a DMat4

§

type Output = DVec4

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<DVec4> for DMat4

§

type Output = DVec4

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<DVec4> for f64

§

type Output = DVec4

The resulting type after applying the * operator.
source§

fn mul(self, arg: DVec4) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<f64> for DVec4

§

type Output = DVec4

The resulting type after applying the * operator.
source§

fn mul(self, arg: f64) -> Self::Output

Performs the * operation. Read more
source§

impl MulAssign<f64> for DVec4

source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
source§

impl PartialEq<DVec4> for DVec4

source§

fn eq(&self, other: &DVec4) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Sub<DVec4> for DVec4

§

type Output = DVec4

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl SubAssign<DVec4> for DVec4

source§

fn sub_assign(&mut self, rhs: DVec4)

Performs the -= operation. Read more
source§

impl<'a> Sum<&'a DVec4> for DVec4

source§

fn sum<I>(iter: I) -> Selfwhere I: Iterator<Item = &'a Self>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Sum<DVec4> for DVec4

source§

fn sum<I>(iter: I) -> Selfwhere I: Iterator<Item = Self>,

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Copy for DVec4

source§

impl StructuralPartialEq for DVec4

Auto Trait Implementations§

§

impl RefUnwindSafe for DVec4

§

impl Send for DVec4

§

impl Sync for DVec4

§

impl Unpin for DVec4

§

impl UnwindSafe for DVec4

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.