Struct dessin::Vec2

source ·
pub struct Vec2 {
    pub x: f32,
    pub y: f32,
}
Expand description

Struct representing a vector or a point in 2D space.

Fields§

§x: f32§y: f32

Implementations§

source§

impl Vec2

source

pub const fn zero() -> Vec2

Vector of zeros.

source

pub const fn ones() -> Vec2

Vector of ones.

source

pub const fn from_cartesian(_: (f32, f32)) -> Vec2

source

pub fn from_polar_deg(mag: f32, angle_deg: f32) -> Vec2

source

pub fn from_polar_rad(mag: f32, angle_rad: f32) -> Vec2

source

pub fn rot_deg(&self, deg: f32) -> Vec2

source

pub fn rot_rad(&self, rad: f32) -> Vec2

source

pub fn abs(&self) -> Vec2

Absolute value.

source

pub fn dot(a: &Vec2, b: &Vec2) -> f32

Dot product.

Trait Implementations§

source§

impl Add<Vec2> for Keypoint

§

type Output = Keypoint

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl Add<Vec2> for Vec2

§

type Output = Vec2

The resulting type after applying the + operator.
source§

fn add(self, rhs: Vec2) -> <Vec2 as Add<Vec2>>::Output

Performs the + operation. Read more
source§

impl Add<f32> for Vec2

§

type Output = Vec2

The resulting type after applying the + operator.
source§

fn add(self, rhs: f32) -> <Vec2 as Add<f32>>::Output

Performs the + operation. Read more
source§

impl AddAssign<Vec2> for Keypoint

source§

fn add_assign(&mut self, rhs: Vec2)

Performs the += operation. Read more
source§

impl AddAssign<Vec2> for Vec2

source§

fn add_assign(&mut self, rhs: Vec2)

Performs the += operation. Read more
source§

impl AddAssign<f32> for Vec2

source§

fn add_assign(&mut self, rhs: f32)

Performs the += operation. Read more
source§

impl Clone for Vec2

source§

fn clone(&self) -> Vec2

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 Vec2

source§

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

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

impl Default for Vec2

source§

fn default() -> Vec2

Returns the “default value” for a type. Read more
source§

impl Div<f32> for Vec2

§

type Output = Vec2

The resulting type after applying the / operator.
source§

fn div(self, rhs: f32) -> <Vec2 as Div<f32>>::Output

Performs the / operation. Read more
source§

impl DivAssign<f32> for Vec2

source§

fn div_assign(&mut self, rhs: f32)

Performs the /= operation. Read more
source§

impl From<(f32, f32)> for Vec2

source§

fn from(_: (f32, f32)) -> Vec2

Converts to this type from the input type.
source§

impl Into<Keypoint> for Vec2

source§

fn into(self) -> Keypoint

Converts this type into the (usually inferred) input type.
source§

impl Mul<Vec2> for Keypoint

§

type Output = Keypoint

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul<Vec2> for Vec2

§

type Output = Vec2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vec2) -> <Vec2 as Mul<Vec2>>::Output

Performs the * operation. Read more
source§

impl Mul<f32> for Vec2

§

type Output = Vec2

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f32) -> <Vec2 as Mul<f32>>::Output

Performs the * operation. Read more
source§

impl MulAssign<Vec2> for Keypoint

source§

fn mul_assign(&mut self, rhs: Vec2)

Performs the *= operation. Read more
source§

impl MulAssign<Vec2> for Vec2

source§

fn mul_assign(&mut self, rhs: Vec2)

Performs the *= operation. Read more
source§

impl MulAssign<f32> for Vec2

source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
source§

impl Neg for Vec2

§

type Output = Vec2

The resulting type after applying the - operator.
source§

fn neg(self) -> <Vec2 as Neg>::Output

Performs the unary - operation. Read more
source§

impl PartialEq<Vec2> for Vec2

source§

fn eq(&self, other: &Vec2) -> 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 PartialOrd<Vec2> for Vec2

source§

fn partial_cmp(&self, other: &Vec2) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<Vec2> for Keypoint

§

type Output = Keypoint

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Sub<Vec2> for Vec2

§

type Output = Vec2

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Vec2) -> <Vec2 as Sub<Vec2>>::Output

Performs the - operation. Read more
source§

impl Sub<f32> for Vec2

§

type Output = Vec2

The resulting type after applying the - operator.
source§

fn sub(self, rhs: f32) -> <Vec2 as Sub<f32>>::Output

Performs the - operation. Read more
source§

impl SubAssign<Vec2> for Keypoint

source§

fn sub_assign(&mut self, rhs: Vec2)

Performs the -= operation. Read more
source§

impl SubAssign<Vec2> for Vec2

source§

fn sub_assign(&mut self, rhs: Vec2)

Performs the -= operation. Read more
source§

impl SubAssign<f32> for Vec2

source§

fn sub_assign(&mut self, rhs: f32)

Performs the -= operation. Read more
source§

impl Copy for Vec2

source§

impl StructuralPartialEq for Vec2

Auto Trait Implementations§

§

impl RefUnwindSafe for Vec2

§

impl Send for Vec2

§

impl Sync for Vec2

§

impl Unpin for Vec2

§

impl UnwindSafe for Vec2

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.