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.