Struct axgeom::Vec2

source ·
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>

source

pub fn abs(&self) -> Vec2<S>

source

pub fn rotate_90deg_right(&self) -> Vec2<S>

source

pub fn rotate_90deg_left(&self) -> Vec2<S>

source

pub fn split_into_components(&self) -> [Vec2<S>; 2]

source§

impl<S: Add<Output = S> + Sub<Output = S> + PartialOrd + Copy> Vec2<S>

source

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>

source

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: Mul<Output = S> + Div<Output = S> + Add<Output = S> + Copy> Vec2<S>

source

pub fn scale(&self, other: Vec2<S>) -> Vec2<S>

source

pub fn inv_scale(&self, other: Vec2<S>) -> Vec2<S>

source

pub fn magnitude2(&self) -> S

source

pub fn dot(&self, other: Vec2<S>) -> S

source§

impl<S: FloatCore> Vec2<S>

source

pub fn is_nan(&self) -> bool

source§

impl<S: Float> Vec2<S>

source

pub fn truncate_at(&self, mag: S) -> Vec2<S>

source

pub fn normalize_to(&self, mag: S) -> Vec2<S>

source

pub fn magnitude(&self) -> S

source§

impl<T> Vec2<T>

source

pub fn inner_as<B: 'static + Copy>(self) -> Vec2<B>where T: AsPrimitive<B>,

source§

impl<B> Vec2<B>

source

pub fn get_axis(&self, axis: impl Axis) -> &B

Get the range of one axis.

source

pub fn get_axis_mut(&mut self, axis: impl Axis) -> &mut B

Get the mutable range of one axis.

source

pub fn inner_into<A>(self) -> Vec2<A>where B: Into<A>,

source

pub fn inner_try_into<A>(self) -> Result<Vec2<A>, B::Error>where B: TryInto<A>,

Trait Implementations§

source§

impl<S: Add<Output = S> + Copy> Add<Vec2<S>> for Vec2<S>

§

type Output = Vec2<S>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<S: AddAssign<S> + Copy> AddAssign<Vec2<S>> for Vec2<S>

source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
source§

impl<N> AsMut<[N; 2]> for Vec2<N>

source§

fn as_mut(&mut self) -> &mut [N; 2]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<N> AsRef<[N; 2]> for Vec2<N>

source§

fn as_ref(&self) -> &[N; 2]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<N: Clone> Clone for Vec2<N>

source§

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

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

source§

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

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

impl<N: Default> Default for Vec2<N>

source§

fn default() -> Vec2<N>

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

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<S: Div<Output = S> + Copy> Div<S> for Vec2<S>

§

type Output = Vec2<S>

The resulting type after applying the / operator.
source§

fn div(self, rhs: S) -> Self

Performs the / operation. Read more
source§

impl<S: DivAssign<S> + Copy> DivAssign<S> for Vec2<S>

source§

fn div_assign(&mut self, scalar: S)

Performs the /= operation. Read more
source§

impl<'a, B: Copy> From<&'a [B; 2]> for Vec2<B>

source§

fn from(a: &'a [B; 2]) -> Self

Converts to this type from the input type.
source§

impl<'a, B> From<&'a Vec2<B>> for &'a [B; 2]

source§

fn from(a: &'a Vec2<B>) -> Self

Converts to this type from the input type.
source§

impl<B> From<[B; 2]> for Vec2<B>

source§

fn from(a: [B; 2]) -> Self

Converts to this type from the input type.
source§

impl<B> From<Vec2<B>> for [B; 2]

source§

fn from(a: Vec2<B>) -> Self

Converts to this type from the input type.
source§

impl<N: Hash> Hash for Vec2<N>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<S: Mul<Output = S> + Copy> Mul<S> for Vec2<S>

§

type Output = Vec2<S>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: S) -> Self

Performs the * operation. Read more
source§

impl<S: MulAssign<S> + Copy> MulAssign<S> for Vec2<S>

source§

fn mul_assign(&mut self, scalar: S)

Performs the *= operation. Read more
source§

impl<S: Neg<Output = S>> Neg for Vec2<S>

§

type Output = Vec2<S>

The resulting type after applying the - operator.
source§

fn neg(self) -> Vec2<S>

Performs the unary - operation. Read more
source§

impl<N: PartialEq> PartialEq<Vec2<N>> for Vec2<N>

source§

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

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<S: Sub<Output = S> + Copy> Sub<Vec2<S>> for Vec2<S>

§

type Output = Vec2<S>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<S: SubAssign<S> + Copy> SubAssign<Vec2<S>> for Vec2<S>

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl<S: Zero + Eq + Copy> Zero for Vec2<S>

source§

fn zero() -> Vec2<S>

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl<N: Copy> Copy for Vec2<N>

source§

impl<N: Eq> Eq for Vec2<N>

source§

impl<N> StructuralEq for Vec2<N>

source§

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> 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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 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.
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.
source§

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

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,