Type Alias citro3d::math::FVec3

source ·
pub type FVec3 = FVec<3>;
Expand description

A 3-vector of f32s.

Aliased Type§

struct FVec3(/* private fields */);

Implementations§

source§

impl FVec3

source

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

Create a new FVec3 from its components.

§Example
let v = FVec3::new(1.0, 2.0, 3.0);
source

pub fn splat(v: f32) -> Self

Create a new FVec3, setting each component to the given v.

§Example
let v = FVec3::splat(1.0);
source

pub fn distance(self, rhs: Self) -> f32

The distance between two points in 3D space.

§Example
let l = FVec3::new(1.0, 3.0, 4.0);
let r = FVec3::new(0.0, 1.0, 2.0);

assert_abs_diff_eq!(l.distance(r), 3.0);
source

pub fn cross(self, rhs: Self) -> Self

The cross product of two 3D vectors.

§Example
let l = FVec3::new(1.0, 0.0, 0.0);
let r = FVec3::new(0.0, 1.0, 0.0);
assert_abs_diff_eq!(l.cross(r), FVec3::new(0.0, 0.0, 1.0));
source

pub fn dot(self, rhs: Self) -> f32

The dot product of two vectors.

§Example
let l = FVec3::new(1.0, 2.0, 3.0);
let r = FVec3::new(3.0, 2.0, 1.0);
assert_abs_diff_eq!(l.dot(r), 10.0);
source

pub fn magnitude(self) -> f32

The magnitude of the vector.

§Example
let v = FVec3::splat(3.0f32.sqrt());
assert_abs_diff_eq!(v.magnitude(), 3.0);
source

pub fn normalize(self) -> Self

Normalize the vector to a magnitude of 1.0.

§Example
let v = FVec3::splat(1.0);
assert_abs_diff_eq!(v.normalize(), FVec3::splat(1.0 / 3.0_f32.sqrt()));

Trait Implementations§

source§

impl Add for FVec3

§

type Output = FVec<3>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl From<Vec3> for FVec3

Available on crate feature glam only.
source§

fn from(value: Vec3) -> Self

Converts to this type from the input type.
source§

impl Mul<f32> for FVec3

§

type Output = FVec<3>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Neg for FVec3

§

type Output = FVec<3>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl Sub for FVec3

§

type Output = FVec<3>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more