Skip to content

struct

Vec3

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

A 3D vector: a point or direction.

Fields

x

pub x: f32

Across.

y

pub y: f32

Up.

z

pub z: f32

Towards the viewer.

Methods

ZERO

pub const ZERO: Vec3;

The origin, (0, 0, 0).

new

pub const fn new(x: f32, y: f32, z: f32) -> Vec3

The vector (x, y, z).

splat

pub const fn splat(v: f32) -> Vec3

The vector with every component v.

dot

pub fn dot(self, o: Vec3) -> f32

The dot product.

cross

pub fn cross(self, o: Vec3) -> Vec3

The cross product.

length

pub fn length(self) -> f32

Its length.

lerp

pub fn lerp(self, o: Vec3, t: f32) -> Vec3

Linear interpolation towards o.

normalize

pub fn normalize(self) -> Vec3

Unit vector in the same direction; the zero vector stays zero.

Trait implementations