[][src]Struct rmath_rs::Vector4

pub struct Vector4 { /* fields omitted */ }

Methods

impl Vector4
[src]

pub fn from1(v: f32) -> Self
[src]

Creates Vector4 instance from one float value. x, y, z and w will be set to the same value.

use rmath_rs::Vector4;
let v = Vector4::from1(0.1);
assert_approx_eq!(v.x(), 0.1);
assert_approx_eq!(v.y(), 0.1);
assert_approx_eq!(v.z(), 0.1);
assert_approx_eq!(v.w(), 0.1);

pub fn from4(x: f32, y: f32, z: f32, w: f32) -> Self
[src]

Creates Vector4 instance from four float values. x, y, z and w will be set to the value of appropriate parameter.

use rmath_rs::Vector4;
let v = Vector4::from4(0.2, 1.1, -2.9, 99.9);
assert_approx_eq!(v.x(), 0.2);
assert_approx_eq!(v.y(), 1.1);
assert_approx_eq!(v.z(), -2.9);
assert_approx_eq!(v.w(), 99.9);

pub fn x(&self) -> f32
[src]

Retrieves x component of Vector4.

use rmath_rs::Vector4;
let v = Vector4::from4(0.2, 1.1, -2.9, 99.9);
assert_approx_eq!(v.x(), 0.2);

pub fn y(&self) -> f32
[src]

Retrieves y component of Vector4.

use rmath_rs::Vector4;
let v = Vector4::from4(0.2, 1.1, -2.9, 99.9);
assert_approx_eq!(v.y(), 1.1);

pub fn z(&self) -> f32
[src]

Retrieves z component of Vector4.

use rmath_rs::Vector4;
let v = Vector4::from4(0.2, 1.1, -2.9, 99.9);
assert_approx_eq!(v.z(), -2.9);

pub fn w(&self) -> f32
[src]

Retrieves w component of Vector4.

use rmath_rs::Vector4;
let v = Vector4::from4(0.2, 1.1, -2.9, 99.9);
assert_approx_eq!(v.w(), 99.9);

pub fn floor(&self) -> Vector4
[src]

Finds the nearest integer less than or equal to the parameter

use rmath_rs::Vector4;
let v = Vector4::from4(0.2, 1.1, -2.9, 99.9);
let v2 = v.floor();
assert_approx_eq!(v2.x(), 0.0);
assert_approx_eq!(v2.y(), 1.0);
assert_approx_eq!(v2.z(), -3.0);
assert_approx_eq!(v2.w(), 99.0);

See: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/floor.xhtml

pub fn abs(&self) -> Vector4
[src]

Finds absolute value of parameter

use rmath_rs::Vector4;
let v = Vector4::from4(0.2, 1.1, -2.9, 99.9);
let v2 = v.abs();
assert_approx_eq!(v2.x(), 0.2);
assert_approx_eq!(v2.y(), 1.1);
assert_approx_eq!(v2.z(), 2.9);
assert_approx_eq!(v2.w(), 99.9);

pub fn fract(&self) -> Vector4
[src]

Computes the fractional part of the argument

use rmath_rs::Vector4;
let v = Vector4::from4(0.2, 1.1, -2.9, 99.9);
let v2 = v.fract();
assert_approx_eq!(v2.x(), 0.2);
assert_approx_eq!(v2.y(), 0.1);
assert_approx_eq!(v2.z(), 0.1);
assert_approx_eq!(v2.w(), 0.9, 1.0e-5); // this one becomes 0.9000015 with regular 1.0e-6 precision :/

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/fract.xhtml

pub fn modulo(&self, other: &Vector4) -> Vector4
[src]

Computes value of one parameter modulo another. Consistent with GLSL implementation

use rmath_rs::Vector4;
let v = Vector4::from4(0.2, 1.1, -2.9, 99.9);
let v2 = Vector4::from1(-1.8);
let v3 = v.modulo(&v2);
assert_approx_eq!(v3.x(), -1.6);
assert_approx_eq!(v3.y(), -0.7);
assert_approx_eq!(v3.z(), -1.1);
assert_approx_eq!(v3.w(), -0.9, 1.0e-5);

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/mod.xhtml

pub fn modulo_euclidean(&self, other: &Vector4) -> Vector4
[src]

Computes value of one parameter modulo another. Consistent with Euclidean division algorithm.

use rmath_rs::Vector4;
let v = Vector4::from4(0.2, 1.1, -2.9, 99.9);
let v2 = Vector4::from1(-1.8);
let v3 = v.modulo_euclidean(&v2);
assert_approx_eq!(v3.x(), 0.2);
assert_approx_eq!(v3.y(), 1.1);
assert_approx_eq!(v3.z(), 0.7);
assert_approx_eq!(v3.w(), 0.9, 1.0e-5);

pub fn distance_sq(&self, other: &Vector4) -> f32
[src]

Computes value of distance squared between two vectors

use rmath_rs::Vector4;
let v1 = Vector4::from4(0.2, 1.1, -2.9, 99.9);
let v2 = Vector4::from4(0.9, 1.8, 2.9, -14.4);
let d = v1.distance_sq(&v2);
assert_approx_eq!(d, 13099.11);

pub fn distance(&self, other: &Vector4) -> f32
[src]

Computes value of distance between two vectors

use rmath_rs::Vector4;
let v1 = Vector4::from4(0.2, 1.1, -2.9, 99.9);
let v2 = Vector4::from4(0.9, 1.8, 2.9, -14.4);
let d = v1.distance(&v2);
assert_approx_eq!(d, 114.45134, 1.0e-5);

Trait Implementations

impl Debug for Vector4
[src]

impl<'_, '_> Add<&'_ Vector4> for &'_ Vector4
[src]

type Output = Vector4

The resulting type after applying the + operator.

fn add(self, other: &Vector4) -> Vector4
[src]

Implements Add trait for Vector4. Operator +(Vector4, Vector4).

use rmath_rs::Vector4;
let v1 = Vector4::from1(0.1);
let v2 = Vector4::from1(1.8);
let v3 = &v1 + &v2;
assert_approx_eq!(v3.x(), 1.9);
assert_approx_eq!(v3.y(), 1.9);
assert_approx_eq!(v3.z(), 1.9);
assert_approx_eq!(v3.w(), 1.9);

impl<'_> Add<f32> for &'_ Vector4
[src]

type Output = Vector4

The resulting type after applying the + operator.

fn add(self, other: f32) -> Vector4
[src]

Implements Add trait for Vector4. Operator +(Vector4, f32).

use rmath_rs::Vector4;
let v1 = Vector4::from1(0.1);
let v2 = &v1 + 1.8;
assert_approx_eq!(v2.x(), 1.9);

impl<'_> Sub<&'_ Vector4> for &'_ Vector4
[src]

type Output = Vector4

The resulting type after applying the - operator.

fn sub(self, other: &Vector4) -> Vector4
[src]

Implements Sub trait for Vector4. Operator -(Vector4, Vector4).

use rmath_rs::Vector4;
let v1 = Vector4::from1(0.1);
let v2 = Vector4::from1(1.8);
let v3 = &v1 - &v2;
assert_approx_eq!(v3.x(), -1.7);

impl<'_> Sub<f32> for &'_ Vector4
[src]

type Output = Vector4

The resulting type after applying the - operator.

fn sub(self, other: f32) -> Vector4
[src]

Implements Sub trait for Vector4. Operator -(Vector4, f32).

use rmath_rs::Vector4;
let v1 = Vector4::from1(0.1);
let v2 = &v1 - 1.8;
assert_approx_eq!(v2.x(), -1.7);

impl<'_> Mul<&'_ Vector4> for &'_ Vector4
[src]

type Output = Vector4

The resulting type after applying the * operator.

fn mul(self, other: &Vector4) -> Vector4
[src]

Implements Mul trait for Vector4. Operator *(Vector4, Vector4).

use rmath_rs::Vector4;
let v1 = Vector4::from1(0.1);
let v2 = Vector4::from1(1.8);
let v3 = &v1 * &v2;
assert_approx_eq!(v3.x(), 0.18);

impl<'_> Mul<f32> for &'_ Vector4
[src]

type Output = Vector4

The resulting type after applying the * operator.

fn mul(self, other: f32) -> Vector4
[src]

Implements Mul trait for Vector4. Operator *(Vector4, f32).

use rmath_rs::Vector4;
let v1 = Vector4::from1(0.1);
let v2 = &v1 * 1.8;
assert_approx_eq!(v2.x(), 0.18);

impl<'_> Div<&'_ Vector4> for &'_ Vector4
[src]

type Output = Vector4

The resulting type after applying the / operator.

fn div(self, other: &Vector4) -> Vector4
[src]

Implements Div trait for Vector4. Operator /(Vector4, Vector4).

use rmath_rs::Vector4;
let v1 = Vector4::from1(0.1);
let v2 = Vector4::from1(1.8);
let v3 = &v1 / &v2;
assert_approx_eq!(v3.x(), 0.055555556);

impl<'_> Div<f32> for &'_ Vector4
[src]

type Output = Vector4

The resulting type after applying the / operator.

fn div(self, other: f32) -> Vector4
[src]

Implements Div trait for Vector4. Operator /(Vector4, f32).

use rmath_rs::Vector4;
let v1 = Vector4::from1(0.1);
let v2 = &v1 / 1.8;
assert_approx_eq!(v2.x(), 0.055555556);

impl<'_> Neg for &'_ Vector4
[src]

type Output = Vector4

The resulting type after applying the - operator.

fn neg(self) -> Vector4
[src]

Implements Neg trait for Vector4. Operator -(Vector4).

use rmath_rs::Vector4;
let v = Vector4::from4(0.2, 1.1, -2.9, 99.9);
let v2 = -&v;
assert_approx_eq!(v2.x(), -0.2);
assert_approx_eq!(v2.y(), -1.1);
assert_approx_eq!(v2.z(), 2.9);
assert_approx_eq!(v2.w(), -99.9);

Auto Trait Implementations

impl Send for Vector4

impl Sync for Vector4

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]