pub struct Vec2<N> {
pub x: N,
pub y: N,
}
Expand description
A 2D vector.
Fields§
§x: N
§y: N
Implementations§
source§impl<S: Copy + Neg<Output = S> + PartialOrd + Zero> Vec2<S>
impl<S: Copy + Neg<Output = S> + PartialOrd + Zero> Vec2<S>
pub fn abs(&self) -> Vec2<S>
pub fn rotate_90deg_right(&self) -> Vec2<S>
pub fn rotate_90deg_left(&self) -> Vec2<S>
pub fn split_into_components(&self) -> [Vec2<S>; 2]
source§impl<S: Add<Output = S> + Sub<Output = S> + PartialOrd + Copy> Vec2<S>
impl<S: Add<Output = S> + Sub<Output = S> + PartialOrd + Copy> Vec2<S>
pub fn manhattan_dis(&self, other: Vec2<S>) -> S
source§impl<T: Copy + PartialOrd + Sub<Output = T> + Mul<Output = T> + Add<Output = T>> Vec2<T>
impl<T: Copy + PartialOrd + Sub<Output = T> + Mul<Output = T> + Add<Output = T>> Vec2<T>
sourcepub fn distance_squared_to_point(&self, point: Vec2<T>) -> T
pub fn distance_squared_to_point(&self, point: Vec2<T>) -> T
If the point is outside the rectangle, returns the squared distance from a point to a rectangle. If the point is inside the rectangle, it will return None.
source§impl<S: Float> Vec2<S>
impl<S: Float> Vec2<S>
pub fn truncate_at(&self, mag: S) -> Vec2<S>
pub fn normalize_to(&self, mag: S) -> Vec2<S>
pub fn magnitude(&self) -> S
source§impl<T> Vec2<T>
impl<T> Vec2<T>
pub fn inner_as<B: 'static + Copy>(self) -> Vec2<B>where T: AsPrimitive<B>,
Trait Implementations§
source§impl<S: AddAssign<S> + Copy> AddAssign<Vec2<S>> for Vec2<S>
impl<S: AddAssign<S> + Copy> AddAssign<Vec2<S>> for Vec2<S>
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl<'de, N> Deserialize<'de> for Vec2<N>where
N: Deserialize<'de>,
impl<'de, N> Deserialize<'de> for Vec2<N>where N: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<S: DivAssign<S> + Copy> DivAssign<S> for Vec2<S>
impl<S: DivAssign<S> + Copy> DivAssign<S> for Vec2<S>
source§fn div_assign(&mut self, scalar: S)
fn div_assign(&mut self, scalar: S)
Performs the
/=
operation. Read moresource§impl<S: MulAssign<S> + Copy> MulAssign<S> for Vec2<S>
impl<S: MulAssign<S> + Copy> MulAssign<S> for Vec2<S>
source§fn mul_assign(&mut self, scalar: S)
fn mul_assign(&mut self, scalar: S)
Performs the
*=
operation. Read moresource§impl<N: PartialEq> PartialEq<Vec2<N>> for Vec2<N>
impl<N: PartialEq> PartialEq<Vec2<N>> for Vec2<N>
source§impl<S: SubAssign<S> + Copy> SubAssign<Vec2<S>> for Vec2<S>
impl<S: SubAssign<S> + Copy> SubAssign<Vec2<S>> for Vec2<S>
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl<N: Copy> Copy for Vec2<N>
impl<N: Eq> Eq for Vec2<N>
impl<N> StructuralEq for Vec2<N>
impl<N> StructuralPartialEq for Vec2<N>
Auto Trait Implementations§
impl<N> RefUnwindSafe for Vec2<N>where N: RefUnwindSafe,
impl<N> Send for Vec2<N>where N: Send,
impl<N> Sync for Vec2<N>where N: Sync,
impl<N> Unpin for Vec2<N>where N: Unpin,
impl<N> UnwindSafe for Vec2<N>where N: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more