pub struct Vec3D {
    pub x: f64,
    pub y: f64,
    pub z: f64,
}
Expand description

A point in 3D space, using f64s

Fields§

§x: f64

X-coordinate

§y: f64

Y-coordinate

§z: f64

Z-coordinate

Implementations§

source§

impl Vec3D

source

pub const ZERO: Self = _

The Vec3D’s ZERO value

source

pub const ONE: Self = _

The Vec3D’s ONE value

source

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

Create a Vec3D from the provided f64 values

Examples found in repository?
examples/spinning-cube.rs (line 13)
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
fn main() {
    let mut view = View::new(350, 90, ColChar::BACKGROUND);

    let mut viewport = Viewport::new(
        Transform3D::new_tr(Vec3D::new(0.0, 0.0, 5.0), Vec3D::new(-0.5, 0.3, 0.0)),
        FOV,
        view.center(),
    );

    let cube = Mesh3D::default_cube();

    fps_gameloop!(
        {
            view.clear();
            viewport.transform.rotation.y -= 0.05;
        },
        {
            view.blit(
                &viewport.render(vec![&cube], DisplayMode::Solid),
                Wrapping::Ignore,
            );
            view.display_render().unwrap();
        },
        FPS,
        |elapsed: gameloop::Duration, frame_skip| {
            println!(
                "Elapsed: {:.2?}µs | Frame skip: {}",
                elapsed.as_micros(),
                frame_skip
            );
        }
    );
}
source

pub fn as_tuple(&self) -> (f64, f64, f64)

Return the Vec3D as a tuple

source

pub fn dot(&self, other: Vec3D) -> f64

Return the dot product in combination with another Vec3D

source

pub fn dot_self(&self) -> f64

Returns the dot product in combination with itself

source

pub fn magnitude(&self) -> f64

The length/magnitude of the Vec3D

Trait Implementations§

source§

impl Add for Vec3D

§

type Output = Vec3D

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl AddAssign for Vec3D

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl Clone for Vec3D

source§

fn clone(&self) -> Vec3D

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Vec3D

source§

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

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

impl Display for Vec3D

source§

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

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

impl Div<f64> for Vec3D

§

type Output = Vec3D

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl Div for Vec3D

§

type Output = Vec3D

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl DivAssign<f64> for Vec3D

source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
source§

impl DivAssign for Vec3D

source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
source§

impl<T: Into<f64>> From<(T, T, T)> for Vec3D

source§

fn from(value: (T, T, T)) -> Self

Converts to this type from the input type.
source§

impl Mul<Vec3D> for Transform3D

source§

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

Apply the transform to the Vec3D

§

type Output = Vec3D

The resulting type after applying the * operator.
source§

impl Mul<f64> for Vec3D

§

type Output = Vec3D

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul for Vec3D

§

type Output = Vec3D

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl MulAssign<f64> for Vec3D

source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
source§

impl MulAssign for Vec3D

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl Neg for Vec3D

§

type Output = Vec3D

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl PartialEq for Vec3D

source§

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

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

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 Rem for Vec3D

§

type Output = Vec3D

The resulting type after applying the % operator.
source§

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

Performs the % operation. Read more
source§

impl RemAssign for Vec3D

source§

fn rem_assign(&mut self, rhs: Self)

Performs the %= operation. Read more
source§

impl Sub for Vec3D

§

type Output = Vec3D

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl SubAssign for Vec3D

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl Copy for Vec3D

source§

impl StructuralPartialEq for Vec3D

Auto Trait Implementations§

§

impl RefUnwindSafe for Vec3D

§

impl Send for Vec3D

§

impl Sync for Vec3D

§

impl Unpin for Vec3D

§

impl UnwindSafe for Vec3D

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.