Struct dumbmath::vec3f::Vec3f [] [src]

pub struct Vec3f {
    pub x: f32,
    pub y: f32,
    pub z: f32,
}

Vector with three f32 components

Fields

x
y
z

Methods

impl Vec3f

fn new(x: f32, y: f32, z: f32) -> Vec3f

Create a Vec3f from three components

fn from_scalar<T: CastF32>(s: T) -> Vec3f

Create a Vec3f with all components set to the same scalar

fn dot(self, v: Vec3f) -> f32

Inner product

fn cross(self, v: Vec3f) -> Vec3f

Cross product

fn distance(self, v: Vec3f) -> f32

Distance to another point

fn lerp(self, p: Vec3f, t: f32) -> Vec3f

Linearly interpolate between two points by the factor t. When t is zero the result is self, and when t is one the result is p. The range of t is not clamped.

fn magnitude_squared(self) -> f32

Squared length of the vector

fn magnitude(self) -> f32

Length of the vector

fn normalized(self) -> Option<Vec3f>

Create a normalized copy, or None if the magnitude is zero

fn project_onto(self, v: Vec3f) -> Option<Vec3f>

Projection of self into v, or None if the magnitude of b is zero.

Trait Implementations

impl Add for Vec3f

type Output = Vec3f

fn add(self, v: Vec3f) -> Vec3f

impl Add<f32> for Vec3f

type Output = Vec3f

fn add(self, s: f32) -> Vec3f

impl Div for Vec3f

type Output = Vec3f

fn div(self, v: Vec3f) -> Vec3f

impl Mul<Vec3f> for Vec3f

type Output = Vec3f

fn mul(self, v: Vec3f) -> Vec3f

impl Mul<f32> for Vec3f

type Output = Vec3f

fn mul(self, f: f32) -> Vec3f

impl Sub for Vec3f

type Output = Vec3f

fn sub(self, v: Vec3f) -> Vec3f

impl Sub<f32> for Vec3f

type Output = Vec3f

fn sub(self, s: f32) -> Vec3f

Derived Implementations

impl PartialEq for Vec3f

fn eq(&self, __arg_0: &Vec3f) -> bool

fn ne(&self, __arg_0: &Vec3f) -> bool

impl Debug for Vec3f

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl Copy for Vec3f

impl Clone for Vec3f

fn clone(&self) -> Vec3f

fn clone_from(&mut self, source: &Self)