Skip to main content

Point

Struct Point 

Source
pub struct Point<N: Num = f32>(pub N, pub N);

Tuple Fields§

§0: N§1: N

Implementations§

Source§

impl<N: Num> Point<N>

Source

pub fn new_zero_value() -> Self

Source

pub fn new_from_angle(angle: f32, hypot: f32) -> Self

Source

pub fn move_from_angle(self, angle: f32, hypot: f32) -> Self

Source

pub fn x(&self) -> N

Source

pub fn y(&self) -> N

Source

pub fn move_x(&mut self, x: N)

Source

pub fn move_y(&mut self, y: N)

Source

pub fn set_x(&mut self, x: N)

Source

pub fn set_y(&mut self, y: N)

Source

pub fn line_to(self, other: Self) -> Line<N>

Source

pub fn rect_to(self, other: Self) -> Rect<N>

Source

pub fn distance_to(self, other: Self) -> Size<N>

Source

pub fn direction_to(self, other: Self) -> Size<f32>

Source

pub fn to<T: Num + From<N>>(&self) -> Point<T>

This is to allow creating a new Point, which wraps a different number type.

For example Point(1u8, 2u8)::to::<u32>() creates a Point(1u32, 2u32).

Source

pub fn abs(&self) -> Self

Source

pub fn min(self, other: Self) -> Self

Source

pub fn min_x(self, other_x: N) -> Self

Source

pub fn min_y(self, other_y: N) -> Self

Source

pub fn max(self, other: Self) -> Self

Source

pub fn max_x(self, other_x: N) -> Self

Source

pub fn max_y(self, other_y: N) -> Self

Source

pub fn hypot_to(self, other: Point<N>) -> N

Source

pub fn rotate_around_point(self, angle: f32, other: Self) -> Self

Source

pub fn rotate_around_zero(self, rotation: f32) -> Self

Source

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

Source

pub fn interpolate_to(self, other: Point<N>, n: N) -> Point<N>

Source

pub fn to_size(self) -> Size<N>

Source

pub fn swizzle_xy(self) -> Self

Returns a copy of this point (with no changes).

Source

pub fn swizzle_yx(self) -> Self

Returns a copy of this Point with the x and y values swapped.

Source

pub fn swizzle_xx(self) -> Self

Source

pub fn swizzle_yy(self) -> Self

Source

pub fn swizzle_0x(self) -> Self

Source

pub fn swizzle_0y(self) -> Self

Source

pub fn swizzle_x0(self) -> Self

Source

pub fn swizzle_y0(self) -> Self

Source

pub fn into_slice(self) -> [N; 2]

Source§

impl<N: Num + ToSignedClamped> Point<N>
where <N as ToSignedClamped>::Output: Signed,

Source

pub fn to_signed_clamped(self) -> Point<<N as ToSignedClamped>::Output>

Source

pub fn step_direction_to( self, other: Point<N>, ) -> Point<<N as ToSignedClamped>::Output>

Source§

impl<N: Num + Signed> Point<N>

Source

pub fn sign(&self) -> Self

Source

pub fn min_by_abs(self, other: Self) -> Self

Source

pub fn min_x_by_abs(self, other_x: N) -> Self

Source

pub fn min_y_by_abs(self, other_y: N) -> Self

Source

pub fn max_by_abs(self, other: Self) -> Self

Source

pub fn max_x_by_abs(self, other_x: N) -> Self

Source

pub fn max_y_by_abs(self, other_y: N) -> Self

Source

pub fn step(&self) -> Self

Source

pub fn sign_exclusive_dir(&self) -> Self

Source

pub fn flip_x(self) -> Self

Source

pub fn flip_y(self) -> Self

Source§

impl Point<f32>

Source

pub fn overlaps(self, Point: Self, xy1: Self, xy2: Self) -> bool

Source

pub fn floor(self) -> Self

Source

pub fn ceil(self) -> Self

Source

pub fn round(self) -> Self

Source

pub fn cossin(self, angle: f32) -> Self

Trait Implementations§

Source§

impl<N: Num> Add for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<N: Num> Add<Point<N>> for Circle<N>

Source§

type Output = Circle<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: Point<N>) -> Self

Performs the + operation. Read more
Source§

impl<N: Num> Add<Point<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: Point<N>) -> Self

Performs the + operation. Read more
Source§

impl<N: Num> Add<Point<N>> for Rect<N>

Source§

type Output = Rect<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: Point<N>) -> Self

Performs the + operation. Read more
Source§

impl<N> Add<Point<N>> for Transform<N>
where N: Num,

Source§

type Output = Point<N>

The resulting type after applying the + operator.
Source§

fn add(self, point: Self::Output) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Point> for Random

Source§

type Output = Point

The resulting type after applying the + operator.
Source§

fn add(self, Point: Point) -> Point

Performs the + operation. Read more
Source§

impl<N: Num> Add<Size<N>> for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the + operator.
Source§

fn add(self, other: Size<N>) -> Self

Performs the + operation. Read more
Source§

impl<N> Add<Transform<N>> for Point<N>
where N: Num,

Source§

type Output = Point<N>

The resulting type after applying the + operator.
Source§

fn add(self, transform: Transform<N>) -> Self::Output

Performs the + operation. Read more
Source§

impl<N: Num> AddAssign for Point<N>

Source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
Source§

impl<N: Num> AddAssign<Point<N>> for Circle<N>

Source§

fn add_assign(&mut self, other: Point<N>)

Performs the += operation. Read more
Source§

impl<N: Num> AddAssign<Point<N>> for Line<N>

Source§

fn add_assign(&mut self, other: Point<N>)

Performs the += operation. Read more
Source§

impl<N: Num> AddAssign<Point<N>> for Rect<N>

Source§

fn add_assign(&mut self, other: Point<N>)

Performs the += operation. Read more
Source§

impl<N: Num> AddAssign<Size<N>> for Point<N>

Source§

fn add_assign(&mut self, other: Size<N>)

Performs the += operation. Read more
Source§

impl<N: Clone + Num> Clone for Point<N>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<N: Copy + Num> Copy for Point<N>

Source§

impl<N: Debug + Num> Debug for Point<N>

Source§

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

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

impl<N: Num> Display for Point<N>

Source§

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

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

impl<N: Num> Div for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the / operator.
Source§

fn div(self, other: Self) -> Self

Performs the / operation. Read more
Source§

impl<N: Num> Div<N> for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the / operator.
Source§

fn div(self, other: N) -> Self

Performs the / operation. Read more
Source§

impl<N: Num> Div<Point<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<N>) -> Self

Performs the / operation. Read more
Source§

impl Div<Point<f64>> for f64

Source§

type Output = Point<f64>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<f64>) -> Point<f64>

Performs the / operation. Read more
Source§

impl Div<Point<i8>> for i8

Source§

type Output = Point<i8>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<i8>) -> Point<i8>

Performs the / operation. Read more
Source§

impl Div<Point<i16>> for i16

Source§

type Output = Point<i16>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<i16>) -> Point<i16>

Performs the / operation. Read more
Source§

impl Div<Point<i32>> for i32

Source§

type Output = Point<i32>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<i32>) -> Point<i32>

Performs the / operation. Read more
Source§

impl Div<Point<i64>> for i64

Source§

type Output = Point<i64>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<i64>) -> Point<i64>

Performs the / operation. Read more
Source§

impl Div<Point<i128>> for i128

Source§

type Output = Point<i128>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<i128>) -> Point<i128>

Performs the / operation. Read more
Source§

impl Div<Point<isize>> for isize

Source§

type Output = Point<isize>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<isize>) -> Point<isize>

Performs the / operation. Read more
Source§

impl Div<Point<u8>> for u8

Source§

type Output = Point<u8>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<u8>) -> Point<u8>

Performs the / operation. Read more
Source§

impl Div<Point<u16>> for u16

Source§

type Output = Point<u16>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<u16>) -> Point<u16>

Performs the / operation. Read more
Source§

impl Div<Point<u32>> for u32

Source§

type Output = Point<u32>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<u32>) -> Point<u32>

Performs the / operation. Read more
Source§

impl Div<Point<u64>> for u64

Source§

type Output = Point<u64>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<u64>) -> Point<u64>

Performs the / operation. Read more
Source§

impl Div<Point<u128>> for u128

Source§

type Output = Point<u128>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<u128>) -> Point<u128>

Performs the / operation. Read more
Source§

impl Div<Point<usize>> for usize

Source§

type Output = Point<usize>

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<usize>) -> Point<usize>

Performs the / operation. Read more
Source§

impl Div<Point> for f32

Source§

type Output = Point

The resulting type after applying the / operator.
Source§

fn div(self, other: Point<f32>) -> Point<f32>

Performs the / operation. Read more
Source§

impl<N: Num> Div<Size<N>> for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the / operator.
Source§

fn div(self, other: Size<N>) -> Self

Performs the / operation. Read more
Source§

impl<N: Num> DivAssign for Point<N>

Source§

fn div_assign(&mut self, other: Self)

Performs the /= operation. Read more
Source§

impl<N: Num> DivAssign<N> for Point<N>

Source§

fn div_assign(&mut self, other: N)

Performs the /= operation. Read more
Source§

impl<N: Num> DivAssign<Point<N>> for Line<N>

Source§

fn div_assign(&mut self, other: Point<N>)

Performs the /= operation. Read more
Source§

impl<N: Num> DivAssign<Size<N>> for Point<N>

Source§

fn div_assign(&mut self, other: Size<N>)

Performs the /= operation. Read more
Source§

impl<N: Num> From<(N, N)> for Point<N>

Source§

fn from((x, y): (N, N)) -> Self

(N, N) -> Point(N, N)

Source§

impl<N> From<Point<N>> for Transform<N>
where N: Num,

Source§

fn from(p: Point<N>) -> Self

Converts to this type from the input type.
Source§

impl<V: Copy> Index<Point<usize>> for Vec2D<V>

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, pos: Point<usize>) -> &V

Performs the indexing (container[index]) operation. Read more
Source§

impl<V: Copy> IndexMut<Point<usize>> for Vec2D<V>

Source§

fn index_mut(&mut self, pos: Point<usize>) -> &mut V

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<N: Num> Into<(N, N)> for Point<N>

Source§

fn into(self) -> (N, N)

Point(N, N) -> (N, N)

Source§

impl<N: Num> Mul for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
Source§

impl<N: Num> Mul<N> for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the * operator.
Source§

fn mul(self, other: N) -> Self

Performs the * operation. Read more
Source§

impl<N: Num> Mul<Point<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<N>) -> Self

Performs the * operation. Read more
Source§

impl Mul<Point<f64>> for f64

Source§

type Output = Point<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<f64>) -> Point<f64>

Performs the * operation. Read more
Source§

impl Mul<Point<i8>> for i8

Source§

type Output = Point<i8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<i8>) -> Point<i8>

Performs the * operation. Read more
Source§

impl Mul<Point<i16>> for i16

Source§

type Output = Point<i16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<i16>) -> Point<i16>

Performs the * operation. Read more
Source§

impl Mul<Point<i32>> for i32

Source§

type Output = Point<i32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<i32>) -> Point<i32>

Performs the * operation. Read more
Source§

impl Mul<Point<i64>> for i64

Source§

type Output = Point<i64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<i64>) -> Point<i64>

Performs the * operation. Read more
Source§

impl Mul<Point<i128>> for i128

Source§

type Output = Point<i128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<i128>) -> Point<i128>

Performs the * operation. Read more
Source§

impl Mul<Point<isize>> for isize

Source§

type Output = Point<isize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<isize>) -> Point<isize>

Performs the * operation. Read more
Source§

impl Mul<Point<u8>> for u8

Source§

type Output = Point<u8>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<u8>) -> Point<u8>

Performs the * operation. Read more
Source§

impl Mul<Point<u16>> for u16

Source§

type Output = Point<u16>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<u16>) -> Point<u16>

Performs the * operation. Read more
Source§

impl Mul<Point<u32>> for u32

Source§

type Output = Point<u32>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<u32>) -> Point<u32>

Performs the * operation. Read more
Source§

impl Mul<Point<u64>> for u64

Source§

type Output = Point<u64>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<u64>) -> Point<u64>

Performs the * operation. Read more
Source§

impl Mul<Point<u128>> for u128

Source§

type Output = Point<u128>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<u128>) -> Point<u128>

Performs the * operation. Read more
Source§

impl Mul<Point<usize>> for usize

Source§

type Output = Point<usize>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<usize>) -> Point<usize>

Performs the * operation. Read more
Source§

impl Mul<Point> for f32

Source§

type Output = Point

The resulting type after applying the * operator.
Source§

fn mul(self, other: Point<f32>) -> Point<f32>

Performs the * operation. Read more
Source§

impl<N: Num> Mul<Size<N>> for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Size<N>) -> Self

Performs the * operation. Read more
Source§

impl<N: Num> MulAssign for Point<N>

Source§

fn mul_assign(&mut self, other: Self)

Performs the *= operation. Read more
Source§

impl<N: Num> MulAssign<N> for Point<N>

Source§

fn mul_assign(&mut self, other: N)

Performs the *= operation. Read more
Source§

impl<N: Num> MulAssign<Point<N>> for Line<N>

Source§

fn mul_assign(&mut self, other: Point<N>)

Performs the *= operation. Read more
Source§

impl<N: Num> MulAssign<Size<N>> for Point<N>

Source§

fn mul_assign(&mut self, other: Size<N>)

Performs the *= operation. Read more
Source§

impl<N: Num + Signed> Neg for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<N: Num> NumTuple<N> for Point<N>

Source§

fn new(x: N, y: N) -> Self

Source§

fn first(&self) -> N

Source§

fn second(&self) -> N

Source§

fn set_first(&mut self, n: N)

Source§

fn set_second(&mut self, n: N)

Source§

fn set(&mut self, first: N, second: N)

Source§

fn get(&mut self) -> (N, N)

Source§

fn min(self, other: Self) -> Self

Source§

fn max(self, other: Self) -> Self

Source§

fn is_outside(self, xy1: Self, xy2: Self) -> bool

Source§

fn is_inside(self, xy1: Self, xy2: Self) -> bool

Source§

impl<N: PartialEq + Num> PartialEq for Point<N>

Source§

fn eq(&self, other: &Point<N>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<N: Num> Rem for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Self) -> Self

Performs the % operation. Read more
Source§

impl<N: Num> Rem<Point<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Point<N>) -> Self

Performs the % operation. Read more
Source§

impl<N: INum> Shl<N> for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the << operator.
Source§

fn shl(self, other: N) -> Self

Performs the << operation. Read more
Source§

impl<N: INum> ShlAssign<N> for Point<N>

Source§

fn shl_assign(&mut self, other: N)

Performs the <<= operation. Read more
Source§

impl<N: INum> Shr<N> for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the >> operator.
Source§

fn shr(self, other: N) -> Self

Performs the >> operation. Read more
Source§

impl<N: INum> ShrAssign<N> for Point<N>

Source§

fn shr_assign(&mut self, other: N)

Performs the >>= operation. Read more
Source§

impl<N: PartialEq + Num> StructuralPartialEq for Point<N>

Source§

impl<N: Num> Sub for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<N: Num> Sub<Point<N>> for Circle<N>

Source§

type Output = Circle<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Point<N>) -> Self

Performs the - operation. Read more
Source§

impl<N: Num> Sub<Point<N>> for Line<N>

Source§

type Output = Line<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Point<N>) -> Self

Performs the - operation. Read more
Source§

impl<N: Num> Sub<Point<N>> for Rect<N>

Source§

type Output = Rect<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Point<N>) -> Self

Performs the - operation. Read more
Source§

impl Sub<Point> for Random

Source§

type Output = Point

The resulting type after applying the - operator.
Source§

fn sub(self, Point: Point) -> Point

Performs the - operation. Read more
Source§

impl<N: Num> Sub<Size<N>> for Point<N>

Source§

type Output = Point<N>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Size<N>) -> Self

Performs the - operation. Read more
Source§

impl<N: Num> SubAssign for Point<N>

Source§

fn sub_assign(&mut self, other: Self)

Performs the -= operation. Read more
Source§

impl<N: Num> SubAssign<Point<N>> for Circle<N>

Source§

fn sub_assign(&mut self, other: Point<N>)

Performs the -= operation. Read more
Source§

impl<N: Num> SubAssign<Point<N>> for Line<N>

Source§

fn sub_assign(&mut self, other: Point<N>)

Performs the -= operation. Read more
Source§

impl<N: Num> SubAssign<Point<N>> for Rect<N>

Source§

fn sub_assign(&mut self, other: Point<N>)

Performs the -= operation. Read more
Source§

impl<N: Num> SubAssign<Size<N>> for Point<N>

Source§

fn sub_assign(&mut self, other: Size<N>)

Performs the -= operation. Read more
Source§

impl<O: Num, N: Num + ToRounded<O>> ToRounded<Point<O>> for Point<N>

Source§

fn to_rounded(self) -> Point<O>

Returns the value in the new type, but clamped.

Auto Trait Implementations§

§

impl<N> Freeze for Point<N>
where N: Freeze,

§

impl<N> RefUnwindSafe for Point<N>
where N: RefUnwindSafe,

§

impl<N> Send for Point<N>
where N: Send,

§

impl<N> Sync for Point<N>
where N: Sync,

§

impl<N> Unpin for Point<N>
where N: Unpin,

§

impl<N> UnsafeUnpin for Point<N>
where N: UnsafeUnpin,

§

impl<N> UnwindSafe for Point<N>
where N: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.