[][src]Struct duku::Vec3

#[repr(C)]pub struct Vec3 {
    pub x: f32,
    pub y: f32,
    pub z: f32,
}

3-component Vector.

Used for 3D sizing and positioning.

Examples

let point1 = Vec3::new(-10.0, -10.0, -10.0);
let point2 = Vec3::new(10.0, 10.0, 10.0);

// when drawing
t.debug_line(point1, point2);

Fields

x: f32

the X component

y: f32

the Y component

z: f32

the Z component

Implementations

impl Vec3[src]

pub const fn new(x: f32, y: f32, z: f32) -> Self[src]

Create a new vector

pub const fn up() -> Self[src]

Create a vector facing up

pub const fn down() -> Self[src]

Create a vector facing down

pub const fn left() -> Self[src]

Create a vector facing left

pub const fn right() -> Self[src]

Create a vector facing right

pub const fn forward() -> Self[src]

Create a vector facing forward

pub const fn back() -> Self[src]

Create a vector facing back

pub const fn uniform(v: f32) -> Self[src]

Create a new vector with all components with the same value

pub fn dot(&self, other: impl Into<Self>) -> f32[src]

Calculate the dot-product of the vector

pub fn cross(&self, other: impl Into<Self>) -> Self[src]

Calculate the cross-product of the vector

pub fn sqr_length(&self) -> f32[src]

Calculate the squared length of a vector

Can sometimes use this instead of length, because this is faster.

pub fn length(&self) -> f32[src]

Calculate the length of a vector

pub fn unit(&self) -> Self[src]

Calculate the unit vector

The unit vector is of length 1 and can also be thought of as the direction of the vector.

pub fn angle_between(&self, other: impl Into<Self>) -> f32[src]

Calculate the angle between 2 vectors

Resulting angle is in degrees

Examples

let up = Vec3::up();
let right = Vec3::right();
let angle = up.angle_between(right);
// angle is ~90 degrees

pub fn project_onto(&self, other: impl Into<Self>) -> Self[src]

Calculate the projected vector onto some other vector

pub const fn xy(&self) -> Vec2[src]

Get the Vec2 made from this vectors x and y

pub fn floor(&self) -> Self[src]

Floor every component of the vector

pub fn ceil(&self) -> Self[src]

Ceil every component of the vector

pub fn round(&self) -> Self[src]

Round every component of the vector

Trait Implementations

impl Add<Vec3> for Vec3[src]

type Output = Self

The resulting type after applying the + operator.

impl AddAssign<Vec3> for Vec3[src]

impl Clone for Vec3[src]

impl Copy for Vec3[src]

impl Debug for Vec3[src]

impl Default for Vec3[src]

impl Div<f32> for Vec3[src]

type Output = Self

The resulting type after applying the / operator.

impl DivAssign<f32> for Vec3[src]

impl From<[f32; 3]> for Vec3[src]

impl From<(Vec2, f32)> for Vec3[src]

impl From<Rgbf> for Vec3[src]

impl Index<usize> for Vec3[src]

type Output = f32

The returned type after indexing.

impl IndexMut<usize> for Vec3[src]

impl Mul<Vec3> for Mat4[src]

type Output = Vec3

The resulting type after applying the * operator.

impl Mul<Vec3> for Quat[src]

type Output = Vec3

The resulting type after applying the * operator.

impl Mul<f32> for Vec3[src]

type Output = Self

The resulting type after applying the * operator.

impl MulAssign<f32> for Vec3[src]

impl Neg for Vec3[src]

type Output = Self

The resulting type after applying the - operator.

impl PartialEq<Vec3> for Vec3[src]

impl StructuralPartialEq for Vec3[src]

impl Sub<Vec3> for Vec3[src]

type Output = Self

The resulting type after applying the - operator.

impl SubAssign<Vec3> for Vec3[src]

impl<'vec> Sum<&'vec Vec3> for Vec3[src]

Auto Trait Implementations

impl RefUnwindSafe for Vec3

impl Send for Vec3

impl Sync for Vec3

impl Unpin for Vec3

impl UnwindSafe for Vec3

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.