[−][src]Struct obscura::Vec3
Representation of a vector in R3.
Fields
x: f32
y: f32
z: f32
Methods
impl Vec3
[src]
pub fn new(x: f32, y: f32, z: f32) -> Vec3
[src]
pub fn one() -> Vec3
[src]
Create a one vector.
Examples
let x = obscura::Vec3::new(1.0, 1.0, 1.0); let y = obscura::Vec3::one(); assert_eq!(x,y);
pub fn zero() -> Vec3
[src]
Create a zero vector.
Examples
let x = obscura::Vec3::new(0.0, 0.0, 0.0); let y = obscura::Vec3::zero(); assert_eq!(x,y);
pub fn add(a: &Vec3, b: &Vec3) -> Vec3
[src]
Add two Vec3's and return new Vec3 as result.
Examples
let a = obscura::Vec3::new(1.0, 0.0, 0.0); let b = obscura::Vec3::new(0.0, 1.0, 0.0); let c = obscura::Vec3::new(1.0, 1.0, 0.0); let result = obscura::Vec3::add(&a, &b); assert_eq!(result, c);
pub fn sub(a: &Vec3, b: &Vec3) -> Vec3
[src]
Subtract a from b and return new Vec3 as result.
Examples
let a = obscura::Vec3::new(0.0, 1.0, 0.0); let b = obscura::Vec3::new(0.0, 1.0, 0.0); let c = obscura::Vec3::new(0.0, 0.0, 0.0); let result = obscura::Vec3::sub(&a, &b); assert_eq!(result, c);
pub fn dot(a: &Vec3, b: &Vec3) -> f32
[src]
Calcuate dot product (scalar product).
Examples
// Create two orthogonal vectors let a = obscura::Vec3::new(1.0, 0.0, 0.0); let b = obscura::Vec3::new(0.0, 1.0, 0.0); // Result of dot product is 0 let result = obscura::Vec3::dot(&a, &b); assert_eq!(result, 0.0);
pub fn cross(a: &Vec3, b: &Vec3) -> Vec3
[src]
Calcuate cross product and return new Vec3 as result.
Examples
use obscura::Vec3; // Create two vectors let a = Vec3::new(1.0, 0.0, 0.0); let b = Vec3::new(0.0, 1.0, 0.0); // Result of cross product is orthogonal two both assert_eq!( Vec3::cross(&a, &b), Vec3::new(0.0, 0.0, 1.0) );
Trait Implementations
Auto Trait Implementations
impl Send for Vec3
impl Sync for Vec3
impl Unpin for Vec3
impl UnwindSafe for Vec3
impl RefUnwindSafe for Vec3
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,