pub struct Vec2<N> {
pub x: N,
pub y: N,
}
Expand description
A 2D vector.
Fields
x: N
y: N
Implementations
sourceimpl<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]
sourceimpl<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
sourceimpl<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.
sourceimpl<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
sourceimpl<T> Vec2<T>
impl<T> Vec2<T>
pub fn inner_as<B: 'static + Copy>(self) -> Vec2<B> where
T: AsPrimitive<B>,
Trait Implementations
sourceimpl<S: AddAssign<S> + Copy> AddAssign<Vec2<S>> for Vec2<S>
impl<S: AddAssign<S> + Copy> AddAssign<Vec2<S>> for Vec2<S>
sourcefn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the +=
operation. Read more
sourceimpl<'de, N> Deserialize<'de> for Vec2<N> where
N: Deserialize<'de>,
impl<'de, N> Deserialize<'de> for Vec2<N> where
N: Deserialize<'de>,
sourcefn 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
sourceimpl<S: DivAssign<S> + Copy> DivAssign<S> for Vec2<S>
impl<S: DivAssign<S> + Copy> DivAssign<S> for Vec2<S>
sourcefn div_assign(&mut self, scalar: S)
fn div_assign(&mut self, scalar: S)
Performs the /=
operation. Read more
sourceimpl<S: MulAssign<S> + Copy> MulAssign<S> for Vec2<S>
impl<S: MulAssign<S> + Copy> MulAssign<S> for Vec2<S>
sourcefn mul_assign(&mut self, scalar: S)
fn mul_assign(&mut self, scalar: S)
Performs the *=
operation. Read more
sourceimpl<S: SubAssign<S> + Copy> SubAssign<Vec2<S>> for Vec2<S>
impl<S: SubAssign<S> + Copy> SubAssign<Vec2<S>> for Vec2<S>
sourcefn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the -=
operation. Read more
impl<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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more