Struct tato::Vec2

source ·
pub struct Vec2<T> {
    pub x: T,
    pub y: T,
}
Expand description

A generic 2D vector.

Fields§

§x: T§y: T

Implementations§

source§

impl<T> Vec2<T>

source

pub fn new(x: T, y: T) -> Self

source§

impl Vec2<i8>

source

pub fn to_f32(self) -> Vec2<f32>

source§

impl Vec2<f32>

source

pub fn to_i32(self) -> Vec2<i32>

source

pub fn angle_between(&self, other: &Self) -> f32

source§

impl<T> Vec2<T>
where T: Float + Num + PartialOrd + Copy + Display,

source

pub fn zero() -> Self

source

pub fn up() -> Self

source

pub fn down() -> Self

source

pub fn left() -> Self

source

pub fn right() -> Self

source

pub fn horiz(&self) -> Self

source

pub fn vert(&self) -> Self

source

pub fn len(&self) -> T

source

pub fn is_longer_than_zero(&self) -> bool

source

pub fn floor(&self) -> Self

source

pub fn normalize(&self) -> Self

source

pub fn clamp_to_length(self, max_length: T) -> Vec2<T>

source

pub fn clamp_to_rect(self, rect: Rect<T>) -> Vec2<T>

source

pub fn dot(&self, other: &Self) -> T

source

pub fn scale(&self, factor: T) -> Self

source

pub fn subtract(&self, other: &Self) -> Self

source

pub fn rotate(&self, angle: T) -> Self

source

pub fn distance_to(&self, other: Self) -> T

Trait Implementations§

source§

impl<T, V> Add<Vec2<V>> for Rect<T>
where T: Add<Output = T> + Sub<Output = T> + Copy + PartialOrd, V: Into<T>,

§

type Output = Rect<T>

The resulting type after applying the + operator.
source§

fn add(self, other: Vec2<V>) -> Self::Output

Performs the + operation. Read more
source§

impl<T> Add for Vec2<T>
where T: Add<Output = T> + Sub<Output = T> + Copy + PartialOrd,

§

type Output = Vec2<T>

The resulting type after applying the + operator.
source§

fn add(self, other: Vec2<T>) -> Self::Output

Performs the + operation. Read more
source§

impl<T> AddAssign for Vec2<T>
where T: Add<Output = T> + AddAssign + Copy + PartialOrd,

source§

fn add_assign(&mut self, other: Vec2<T>)

Performs the += operation. Read more
source§

impl<T: Clone> Clone for Vec2<T>

source§

fn clone(&self) -> Vec2<T>

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<T: Debug> Debug for Vec2<T>

source§

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

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

impl<T: Default> Default for Vec2<T>

source§

fn default() -> Vec2<T>

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

impl From<Vec2<f32>> for Collider

source§

fn from(value: Vec2<f32>) -> Self

Converts to this type from the input type.
source§

impl<T: PartialEq> PartialEq for Vec2<T>

source§

fn eq(&self, other: &Vec2<T>) -> 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<T, V> Sub<Vec2<V>> for Rect<T>
where T: Add<Output = T> + Sub<Output = T> + Copy + PartialOrd, V: Into<T>,

§

type Output = Rect<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: Vec2<V>) -> Self::Output

Performs the - operation. Read more
source§

impl<T> Sub for Vec2<T>
where T: Add<Output = T> + Sub<Output = T> + Copy + PartialOrd,

§

type Output = Vec2<T>

The resulting type after applying the - operator.
source§

fn sub(self, other: Vec2<T>) -> Self::Output

Performs the - operation. Read more
source§

impl<T> SubAssign for Vec2<T>
where T: Sub<Output = T> + AddAssign + Copy + PartialOrd,

source§

fn sub_assign(&mut self, other: Vec2<T>)

Performs the -= operation. Read more
source§

impl<T: Copy> Copy for Vec2<T>

source§

impl<T> StructuralPartialEq for Vec2<T>

Auto Trait Implementations§

§

impl<T> Freeze for Vec2<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Vec2<T>
where T: RefUnwindSafe,

§

impl<T> Send for Vec2<T>
where T: Send,

§

impl<T> Sync for Vec2<T>
where T: Sync,

§

impl<T> Unpin for Vec2<T>
where T: Unpin,

§

impl<T> UnwindSafe for Vec2<T>
where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where 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 T
where 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 T
where 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.