Struct Vec4

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

Fields§

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

Implementations§

Source§

impl<T> Vec4<T>

Source

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

Source

pub fn as_ptr(&self) -> *const T

Source

pub fn as_mut_ptr(&mut self) -> *mut T

Source

pub fn as_slice(&self) -> &[T]

use gfxmath_vec4::Vec4;
 
let a = Vec4::<f32>::new(1.0, 2.0, 3.0, 4.0);
 
let a_slice = a.as_slice();
 
assert_eq!(1.0, a_slice[0]);
assert_eq!(2.0, a_slice[1]);
assert_eq!(3.0, a_slice[2]);
assert_eq!(4.0, a_slice[3]);
Source

pub fn as_mut_slice(&mut self) -> &mut [T]

use gfxmath_vec4::Vec4;
 
let mut a = Vec4::<f32>::new(1.0, 2.0, 3.0, 4.0);
 
{
    let a_slice = a.as_mut_slice();
 
    assert_eq!(1.0, a_slice[0]);
    assert_eq!(2.0, a_slice[1]);
    assert_eq!(3.0, a_slice[2]);
    assert_eq!(4.0, a_slice[3]);
 
    a_slice[2] = 108.0;
    assert_eq!(108.0, a_slice[2]); 
}
 
a.x = 4.5;
assert_eq!(4.5, a.x);
 
let a_slice = a.as_mut_slice();
 
assert_eq!(4.5, a_slice[0]);
assert_eq!(2.0, a_slice[1]);
assert_eq!(108.0, a_slice[2]);
assert_eq!(4.0, a_slice[3]);
Source§

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

Source

pub fn all(val: T) -> Self

use gfxmath_vec4::Vec4;
 
let v = Vec4::<f32>::all(2.5);
 
assert_eq!(2.5, v.x);
assert_eq!(2.5, v.y);
assert_eq!(2.5, v.z);
assert_eq!(2.5, v.w);

Trait Implementations§

Source§

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

Source§

type Output = Vec4<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

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

Source§

type Output = Vec4<T>

The resulting type after applying the + operator.
Source§

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

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>) -> Self::Output

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>) -> Self::Output

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>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&Vec4<i64>> for i64

Source§

type Output = Vec4<i64>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Vec4<i64>) -> Self::Output

Performs the + operation. Read more
Source§

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

Source§

type Output = Vec4<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<T> for Vec4<T>
where T: Add<Output = T> + Copy,

Source§

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

use gfxmath_vec4 ::Vec4;
 
let v = Vec4::<f32>::new(1.0, 2.0, 3.0, 4.0);

let res: Vec4<f32> = (v + 3.0).into();
 
assert_eq!(4.0, res.x);
assert_eq!(5.0, res.y);
assert_eq!(6.0, res.z);
assert_eq!(7.0, res.w);
Source§

type Output = Vec4<T>

The resulting type after applying the + operator.
Source§

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

Source§

type Output = Vec4<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<Vec4<f32>> for f32

Source§

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

use gfxmath_vec4 ::Vec4;
 
let v = Vec4::<f32>::new(1.0, 2.0, 3.0, 4.0);

let res: Vec4<f32> = (3.0 + v).into();
 
assert_eq!(4.0, res.x);
assert_eq!(5.0, res.y);
assert_eq!(6.0, res.z);
assert_eq!(7.0, res.w);
Source§

type Output = Vec4<f32>

The resulting type after applying the + operator.
Source§

impl Add<Vec4<f64>> for f64

Source§

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

use gfxmath_vec4 ::Vec4;
 
let v = Vec4::<f64>::new(1.0, 2.0, 3.0, 4.0);

let res: Vec4<f64> = (3.0 + v).into();
 
assert_eq!(4.0, res.x);
assert_eq!(5.0, res.y);
assert_eq!(6.0, res.z);
assert_eq!(7.0, res.w);
Source§

type Output = Vec4<f64>

The resulting type after applying the + operator.
Source§

impl Add<Vec4<i32>> for i32

Source§

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

use gfxmath_vec4 ::Vec4;
 
let v = Vec4::<i32>::new(1, 2, 3, 4);

let res = 3 + v;
 
assert_eq!(4, res.x);
assert_eq!(5, res.y);
assert_eq!(6, res.z);
assert_eq!(7, res.w);
Source§

type Output = Vec4<i32>

The resulting type after applying the + operator.
Source§

impl Add<Vec4<i64>> for i64

Source§

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

use gfxmath_vec4 ::Vec4;
 
let v = Vec4::<i64>::new(1, 2, 3, 4);

let res = 3 + v;
 
assert_eq!(4, res.x);
assert_eq!(5, res.y);
assert_eq!(6, res.z);
assert_eq!(7, res.w);
Source§

type Output = Vec4<i64>

The resulting type after applying the + operator.
Source§

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

Source§

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

use gfxmath_vec4 ::Vec4;
let a = Vec4::new(1.0, 2.0, 3.0, 4.0);
let b = Vec4::new(3.0, 4.0, 5.0, 6.0);
 
let res: Vec4<f32> = &a + &b;
 
assert_eq!(1.0, a.x);
assert_eq!(2.0, a.y);
assert_eq!(3.0, a.z);
assert_eq!(4.0, a.w);
 
assert_eq!(3.0, b.x);
assert_eq!(4.0, b.y);
assert_eq!(5.0, b.z);
assert_eq!(6.0, b.w);
 
assert_eq!(4.0, res.x);
assert_eq!(6.0, res.y);
assert_eq!(8.0, res.z);
assert_eq!(10.0, res.w);
Source§

type Output = Vec4<T>

The resulting type after applying the + operator.
Source§

impl<T> AddAssign<&Vec4<T>> for Vec4<T>
where T: AddAssign<T> + Copy,

Source§

fn add_assign(&mut self, rhs: &Vec4<T>)

Performs the += operation. Read more
Source§

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

Source§

fn add_assign(&mut self, rhs: T)

use gfxmath_vec4::Vec4;
let mut a = Vec4::new(1.0, 2.0, 3.0, 8.0);
a += 4.0;
 
assert_eq!(5.0, a.x);
assert_eq!(6.0, a.y);
assert_eq!(7.0, a.z);
assert_eq!(12.0, a.w);
Source§

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

Source§

fn add_assign(&mut self, rhs: Vec4<T>)

use gfxmath_vec4::Vec4;
 
let mut a = Vec4::new(1.0, 2.0, 3.0, 4.0);
let b = Vec4::all(3.0);
 
a += b;
 
assert_eq!(4.0, a.x);
assert_eq!(5.0, a.y);
assert_eq!(6.0, a.z);
assert_eq!(7.0, a.w);
Source§

impl<T: Clone> Clone for Vec4<T>

Source§

fn clone(&self) -> Vec4<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 Cross<&Vec4<f32>> for &Vec4<f32>

Source§

type Output = Vec4<f32>

Source§

fn cross(self, rhs: &Vec4<f32>) -> Self::Output

Source§

impl Cross<&Vec4<f32>> for Vec4<f32>

Source§

type Output = Vec4<f32>

Source§

fn cross(self, rhs: &Vec4<f32>) -> Self::Output

Source§

impl Cross<&Vec4<f64>> for &Vec4<f64>

Source§

type Output = Vec4<f64>

Source§

fn cross(self, rhs: &Vec4<f64>) -> Self::Output

Source§

impl Cross<&Vec4<f64>> for Vec4<f64>

Source§

type Output = Vec4<f64>

Source§

fn cross(self, rhs: &Vec4<f64>) -> Self::Output

Source§

impl Cross<Vec4<f32>> for &Vec4<f32>

Source§

type Output = Vec4<f32>

Source§

fn cross(self, rhs: Vec4<f32>) -> Self::Output

Source§

impl Cross<Vec4<f64>> for &Vec4<f64>

Source§

type Output = Vec4<f64>

Source§

fn cross(self, rhs: Vec4<f64>) -> Self::Output

Source§

impl Cross for Vec4<f32>

Source§

fn cross(self, rhs: Vec4<f32>) -> Self::Output

use gfxmath_vec4::ops::Cross;
use gfxmath_vec4::Vec4;

let a = Vec4::<f32>::new(1.0, 3.0, 2.5, 0.0);
let b = Vec4::all(2.0);

let res = a.cross(b);
 
assert_eq!(1.0, res.x);
assert_eq!(3.0, res.y);
assert_eq!(-4.0, res.z);
assert_eq!(0.0, res.w);
Source§

type Output = Vec4<f32>

Source§

impl Cross for Vec4<f64>

Source§

fn cross(self, rhs: Vec4<f64>) -> Self::Output

use gfxmath_vec4::ops::Cross;
use gfxmath_vec4::Vec4;

let a = Vec4::<f64>::new(1.0, 3.0, 2.5, 0.0);
let b = Vec4::all(2.0);

let res = a.cross(b);
 
assert_eq!(1.0, res.x);
assert_eq!(3.0, res.y);
assert_eq!(-4.0, res.z);
assert_eq!(0.0, res.w);
Source§

type Output = Vec4<f64>

Source§

impl<T: Debug> Debug for Vec4<T>

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: Div<Output = T> + Copy,

Source§

type Output = Vec4<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<T> for Vec4<T>
where T: Div<Output = T> + Copy,

Source§

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

Scalar division with vector

use gfxmath_vec4::Vec4;
 
let a = Vec4::<f32>::new(0.5, 2.5, -2.5, 3.0);
let b = Vec4::from(a / 2.0);
 
assert_eq!( 0.25, b.x);
assert_eq!( 1.25, b.y);
assert_eq!(-1.25, b.z);
assert_eq!( 1.5 , b.w);
Source§

type Output = Vec4<T>

The resulting type after applying the / operator.
Source§

impl<T> DivAssign<&Vec4<T>> for Vec4<T>
where T: DivAssign<T> + Copy,

Source§

fn div_assign(&mut self, rhs: &Vec4<T>)

Performs the /= operation. Read more
Source§

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

Source§

fn div_assign(&mut self, rhs: T)

Scalar division with vector

use gfxmath_vec4::Vec4;
 
let mut a = Vec4::<f32>::new(0.5, 2.5, -2.5, 1.0);
a /= 2.0;
 
assert_eq!( 0.25, a.x);
assert_eq!( 1.25, a.y);
assert_eq!(-1.25, a.z);
assert_eq!( 0.5, a.w);
Source§

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

Source§

fn div_assign(&mut self, rhs: Vec4<T>)

Scalar division with vector

use gfxmath_vec4::Vec4;
 
let mut a = Vec4::<f32>::new(0.5, 2.5, -2.5, 3.0);
let b = Vec4::<f32>::new(0.5, 2.5, -2.5, 3.0);
a /= b;
 
assert_eq!(1.0, a.x);
assert_eq!(1.0, a.y);
assert_eq!(1.0, a.z);
assert_eq!(1.0, a.w);
Source§

impl<T> Dot<&Vec4<T>> for &Vec4<T>
where T: Add<Output = T> + Mul<Output = T> + Copy,

Source§

type Output = T

Source§

fn dot(self, rhs: &Vec4<T>) -> Self::Output

Source§

impl<T> Dot<&Vec4<T>> for Vec4<T>
where T: Add<Output = T> + Mul<Output = T> + Copy,

Source§

type Output = T

Source§

fn dot(self, rhs: &Vec4<T>) -> Self::Output

Source§

impl<T> Dot<Vec4<T>> for &Vec4<T>
where T: Add<Output = T> + Mul<Output = T> + Copy,

Source§

type Output = T

Source§

fn dot(self, rhs: Vec4<T>) -> Self::Output

Source§

impl<T> Dot for Vec4<T>
where T: Add<Output = T> + Mul<Output = T> + Copy,

Source§

fn dot(self, rhs: Vec4<T>) -> Self::Output

use gfxmath_vec4::{Vec4, ops::Dot};
 
let a = Vec4::new(3.0, 4.0, 5.0, 3.0);
let b = Vec4::new(2.0, 1.0, 3.0, 3.0);
 
let res = a.dot(b);
 
assert_eq!(25.0, res);
Source§

type Output = T

Source§

impl Hash for Vec4<f32>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Hash for Vec4<f64>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Hash for Vec4<i32>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Hash for Vec4<i64>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Hash for Vec4<u32>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Hash for Vec4<u64>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

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

Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

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

Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

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

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>) -> Self::Output

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>) -> Self::Output

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>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&Vec4<i64>> for i64

Source§

type Output = Vec4<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Vec4<i64>) -> Self::Output

Performs the * operation. Read more
Source§

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

Source§

type Output = Vec4<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<T> for Vec4<T>
where T: Mul<Output = T> + Copy,

Source§

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

Scalar multiplication with vector

use gfxmath_vec4::Vec4;
 
let a = Vec4::<f32>::new(0.5, 2.5, -2.5, 4.0);
let b = Vec4::from(a * 2.0);
 
assert_eq!( 1.0, b.x);
assert_eq!( 5.0, b.y);
assert_eq!(-5.0, b.z);
assert_eq!( 8.0, b.w);
Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

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

Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<Vec4<f32>> for f32

Source§

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

Scalar multiplication with vector

use gfxmath_vec4::Vec4;
 
let a = Vec4::<f32>::new(0.5, 2.5, -2.5, 4.0);
let b = Vec4::from(2.0 * a);
 
assert_eq!( 1.0, b.x);
assert_eq!( 5.0, b.y);
assert_eq!(-5.0, b.z);
assert_eq!( 8.0, b.w);
Source§

type Output = Vec4<f32>

The resulting type after applying the * operator.
Source§

impl Mul<Vec4<f64>> for f64

Source§

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

Scalar multiplication with vector

use gfxmath_vec4::Vec4;
 
let a = Vec4::<f64>::new(0.5, 2.5, -2.5, 4.0);
let b = Vec4::from(2.0 * a);
 
assert_eq!( 1.0, b.x);
assert_eq!( 5.0, b.y);
assert_eq!(-5.0, b.z);
assert_eq!( 8.0, b.w);
Source§

type Output = Vec4<f64>

The resulting type after applying the * operator.
Source§

impl Mul<Vec4<i32>> for i32

Source§

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

Scalar multiplication with vector

use gfxmath_vec4::Vec4;
 
let a = Vec4::<i32>::new(5, 2, -2, 4);
let b = Vec4::from(2 * a);
 
assert_eq!( 10, b.x);
assert_eq!( 4, b.y);
assert_eq!(-4, b.z);
assert_eq!( 8, b.w);
Source§

type Output = Vec4<i32>

The resulting type after applying the * operator.
Source§

impl Mul<Vec4<i64>> for i64

Source§

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

Scalar multiplication with vector

use gfxmath_vec4::Vec4;
 
let a = Vec4::<i64>::new(5, 2, -2, 4);
let b = Vec4::from(2 * a);
 
assert_eq!( 10, b.x);
assert_eq!(  4, b.y);
assert_eq!( -4, b.z);
assert_eq!(  8, b.w);
Source§

type Output = Vec4<i64>

The resulting type after applying the * operator.
Source§

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

Source§

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

use gfxmath_vec4::Vec4;
 
let mut a = Vec4::<f32>::new(1.5, 2.5, -2.0, 5.0);
let b = Vec4::<f32>::new(4.0, 2.0,  4.0, 5.0);
let c = Vec4::from(&a * &b);
 
a.x = 2.0;
 
assert_eq!( 6.0, c.x);
assert_eq!( 5.0, c.y);
assert_eq!(-8.0, c.z);
assert_eq!(25.0, c.w);
 
let c = Vec4::from(a * b);

assert_eq!( 8.0, c.x);
assert_eq!( 5.0, c.y);
assert_eq!(-8.0, c.z);
assert_eq!(25.0, c.w);
Source§

type Output = Vec4<T>

The resulting type after applying the * operator.
Source§

impl<T> MulAssign<&Vec4<T>> for Vec4<T>
where T: MulAssign<T> + Copy,

Source§

fn mul_assign(&mut self, rhs: &Vec4<T>)

Performs the *= operation. Read more
Source§

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

Source§

fn mul_assign(&mut self, rhs: T)

use gfxmath_vec4::Vec4;
 
let mut a = Vec4::<f32>::new(1.5, 2.5, -2.0, 9.0);
a *= 2.0;
 
assert_eq!( 3.0, a.x);
assert_eq!( 5.0, a.y);
assert_eq!(-4.0, a.z);
assert_eq!(18.0, a.w); 
Source§

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

Source§

fn mul_assign(&mut self, rhs: Vec4<T>)

use gfxmath_vec4::Vec4;
 
let mut a = Vec4::<f32>::new(1.5, 2.5, -2.0, 3.0);
let b = Vec4::<f32>::new(4.0, 2.0,  4.0, 4.0);
a *= b;
 
assert_eq!( 6.0, a.x);
assert_eq!( 5.0, a.y);
assert_eq!(-8.0, a.z);
assert_eq!(12.0, a.w);
 
Source§

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

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

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

Source§

fn neg(self) -> Self::Output

use gfxmath_vec4::ops::Cross;
use gfxmath_vec4::Vec4;

let a = Vec4::new(1.0, 3.0, 2.5, -3.0);

let res = -a;
 
assert_eq!(-1.0, res.x);
assert_eq!(-3.0, res.y);
assert_eq!(-2.5, res.z);
assert_eq!( 3.0, res.w);
Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

impl Norm for &Vec4<f32>

Source§

type Output = Option<Vec4<f32>>

Source§

fn norm(self) -> Self::Output

Source§

impl Norm for &Vec4<f64>

Source§

type Output = Option<Vec4<f64>>

Source§

fn norm(self) -> Self::Output

Source§

impl Norm for Vec4<f32>

Source§

fn norm(self) -> Self::Output

use gfxmath_vec4::ops::Norm;
use gfxmath_vec4::Vec4;
 
let a = Vec4::<f32>::new(3.0, 4.0, 0.0, 0.0);
let an = a.norm().unwrap();
 
assert_eq!(3.0/5.0, an.x);
assert_eq!(4.0/5.0, an.y);
assert_eq!(0.0, an.z);
assert_eq!(0.0, an.w);
Source§

type Output = Option<Vec4<f32>>

Source§

impl Norm for Vec4<f64>

Source§

fn norm(self) -> Self::Output

use gfxmath_vec4::ops::Norm;
use gfxmath_vec4::Vec4;
 
let a = Vec4::<f64>::new(3.0, 4.0, 0.0, 0.0);
let an = a.norm().unwrap();
 
assert_eq!(3.0/5.0, an.x);
assert_eq!(4.0/5.0, an.y);
assert_eq!(0.0, an.z);
assert_eq!(0.0, an.w);
Source§

type Output = Option<Vec4<f64>>

Source§

impl<T: PartialEq> PartialEq for Vec4<T>

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> Sub<&Vec4<T>> for &Vec4<T>
where T: Sub<Output = T> + Copy,

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

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

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

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

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>) -> Self::Output

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>) -> Self::Output

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>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&Vec4<i64>> for i64

Source§

type Output = Vec4<i64>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Vec4<i64>) -> Self::Output

Performs the - operation. Read more
Source§

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

Source§

type Output = Vec4<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<T> for Vec4<T>
where T: Sub<Output = T> + Copy,

Source§

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

use gfxmath_vec4::Vec4;
 
let v = Vec4::new(1.0, 2.0, 3.0, 4.0);

let res = v - 3.0;
 
assert_eq!(-2.0, res.x);
assert_eq!(-1.0, res.y);
assert_eq!( 0.0, res.z);
assert_eq!( 1.0, res.w);
Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

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

Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<Vec4<f32>> for f32

Source§

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

use gfxmath_vec4::Vec4;
 
let v = Vec4::<f32>::new(1.0, 2.0, 3.0, 4.0);
 
let res = 3.0 - v;
 
assert_eq!( 2.0, res.x);
assert_eq!( 1.0, res.y);
assert_eq!( 0.0, res.z);
assert_eq!(-1.0, res.w);
Source§

type Output = Vec4<f32>

The resulting type after applying the - operator.
Source§

impl Sub<Vec4<f64>> for f64

Source§

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

use gfxmath_vec4::Vec4;
 
let v = Vec4::<f64>::new(1.0, 2.0, 3.0, 4.0);
 
let res = 3.0 - v;
 
assert_eq!( 2.0, res.x);
assert_eq!( 1.0, res.y);
assert_eq!( 0.0, res.z);
assert_eq!(-1.0, res.w);
Source§

type Output = Vec4<f64>

The resulting type after applying the - operator.
Source§

impl Sub<Vec4<i32>> for i32

Source§

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

use gfxmath_vec4::Vec4;
 
let v = Vec4::<i32>::new(1, 2, 3, 4);
 
let res = 3 - v;
 
assert_eq!( 2, res.x);
assert_eq!( 1, res.y);
assert_eq!( 0, res.z);
assert_eq!(-1, res.w);
 
Source§

type Output = Vec4<i32>

The resulting type after applying the - operator.
Source§

impl Sub<Vec4<i64>> for i64

Source§

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

use gfxmath_vec4::Vec4;
 
let v = Vec4::<i64>::new(1, 2, 3, 4);
 
let res = 3 - v;
 
assert_eq!( 2, res.x);
assert_eq!( 1, res.y);
assert_eq!( 0, res.z);
assert_eq!(-1, res.w);
Source§

type Output = Vec4<i64>

The resulting type after applying the - operator.
Source§

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

Source§

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

use gfxmath_vec4::Vec4;
 
let mut a = Vec4::<f32>::new(0.5, 2.5, -2.5, 3.0);
let b = Vec4::<f32>::new(1.5, 2.5,  2.0, 4.0);
let c = Vec4::from(&a - &b);
 
a.x = 1.0;
 
assert_eq!(-1.0, c.x);
assert_eq!( 0.0, c.y);
assert_eq!(-4.5, c.z);
assert_eq!(-1.0, c.w);
 
let c2 = Vec4::from(a - b);

assert_eq!(-0.5, c2.x);
assert_eq!( 0.0, c2.y);
assert_eq!(-4.5, c2.z);
assert_eq!(-1.0, c2.w);
Source§

type Output = Vec4<T>

The resulting type after applying the - operator.
Source§

impl<T> SubAssign<&Vec4<T>> for Vec4<T>
where T: SubAssign<T> + Copy,

Source§

fn sub_assign(&mut self, rhs: &Vec4<T>)

Performs the -= operation. Read more
Source§

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

Source§

fn sub_assign(&mut self, rhs: T)

use gfxmath_vec4::Vec4;
 
let mut a = Vec4::<f32>::new(0.5, 2.5, -2.5, 3.0);
 
a -= -1.0;
 
assert_eq!( 1.5, a.x);
assert_eq!( 3.5, a.y);
assert_eq!(-1.5, a.z);
assert_eq!( 4.0, a.w);
Source§

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

Source§

fn sub_assign(&mut self, rhs: Vec4<T>)

use gfxmath_vec4::Vec4;
 
let mut a = Vec4::<f32>::new(0.5, 2.5, -2.5, 4.0);
let mut b = Vec4::<f32>::new(1.5, 2.5,  2.0, 3.0);
a -= b;
 
assert_eq!(-1.0, a.x);
assert_eq!( 0.0, a.y);
assert_eq!(-4.5, a.z);
assert_eq!( 1.0, a.w);
Source§

impl<T> StructuralPartialEq for Vec4<T>

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> 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.