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()));
source§

impl<const N: usize> FVec<N>

source

pub fn x(self) -> f32

The vector’s x component (also called the i component of ijk[r]).

source

pub fn y(self) -> f32

The vector’s y component (also called the j component of ijk[r]).

source

pub fn z(self) -> f32

The vector’s i component (also called the k component of ijk[r]).

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
source§

impl<const N: usize> Clone for FVec<N>

source§

fn clone(&self) -> FVec<N>

Returns a copy of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
source§

impl<const N: usize> Debug for FVec<N>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<const N: usize> Div<f32> for FVec<N>
where FVec<N>: Mul<f32>,

§

type Output = <FVec<N> as Mul<f32>>::Output

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<const N: usize> PartialEq for FVec<N>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const N: usize> Copy for FVec<N>

source§

impl<const N: usize> Eq for FVec<N>