[−][src]Struct duku::Vector3
3-component Vector.
Used for 3D sizing and positioning.
Example
let point_1 = Vector3::new(-10.0, -10.0, -10.0); let point_2 = Vector3::new(10.0, 10.0, 10.0); target.draw_line_debug(point_1, point_2);
Fields
x: f32
the X component
y: f32
the Y component
z: f32
the Z component
Implementations
impl Vector3
[src]
pub const fn new(x: f32, y: f32, z: f32) -> Self
[src]
Create a new vector
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
Note: resulting angle is in degrees
Example
let up = Vector3::UP; let right = Vector3::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) -> Vector2
[src]
Get the Vector2 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
pub const BACK: Self
[src]
Shorthand for Vector3::new(0.0, 0.0, -1.0)
pub const FORWARD: Self
[src]
Shorthand for Vector3::new(0.0, 0.0, 1.0)
pub const UP: Self
[src]
Shorthand for Vector3::new(0.0, 1.0, 0.0)
pub const DOWN: Self
[src]
Shorthand for Vector3::new(0.0, -1.0, 0.0)
pub const LEFT: Self
[src]
Shorthand for Vector3::new(-1.0, 0.0, 0.0)
pub const RIGHT: Self
[src]
Shorthand for Vector3::new(1.0, 0.0, 0.0)
Trait Implementations
impl Add<Vector3> for Vector3
[src]
type Output = Self
The resulting type after applying the +
operator.
pub fn add(self, rhs: Self) -> Self
[src]
impl AddAssign<Vector3> for Vector3
[src]
pub fn add_assign(&mut self, rhs: Self)
[src]
impl Clone for Vector3
[src]
impl Copy for Vector3
[src]
impl Debug for Vector3
[src]
impl Default for Vector3
[src]
impl Div<f32> for Vector3
[src]
type Output = Self
The resulting type after applying the /
operator.
pub fn div(self, rhs: f32) -> Self
[src]
impl DivAssign<f32> for Vector3
[src]
pub fn div_assign(&mut self, rhs: f32)
[src]
impl From<[f32; 3]> for Vector3
[src]
impl From<(Vector2, f32)> for Vector3
[src]
impl From<Color> for Vector3
[src]
impl Index<usize> for Vector3
[src]
impl IndexMut<usize> for Vector3
[src]
impl Mul<Vector3> for Matrix4
[src]
type Output = Vector3
The resulting type after applying the *
operator.
pub fn mul(self, rhs: Vector3) -> Self::Output
[src]
impl Mul<Vector3> for Quaternion
[src]
type Output = Vector3
The resulting type after applying the *
operator.
pub fn mul(self, rhs: Vector3) -> Vector3
[src]
impl Mul<f32> for Vector3
[src]
type Output = Self
The resulting type after applying the *
operator.
pub fn mul(self, rhs: f32) -> Self
[src]
impl MulAssign<f32> for Vector3
[src]
pub fn mul_assign(&mut self, rhs: f32)
[src]
impl Neg for Vector3
[src]
impl PartialEq<Vector3> for Vector3
[src]
impl StructuralPartialEq for Vector3
[src]
impl Sub<Vector3> for Vector3
[src]
type Output = Self
The resulting type after applying the -
operator.
pub fn sub(self, rhs: Self) -> Self
[src]
impl SubAssign<Vector3> for Vector3
[src]
pub fn sub_assign(&mut self, rhs: Self)
[src]
impl<'vec> Sum<&'vec Vector3> for Vector3
[src]
Auto Trait Implementations
impl RefUnwindSafe for Vector3
impl Send for Vector3
impl Sync for Vector3
impl Unpin for Vector3
impl UnwindSafe for Vector3
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,