pub struct Point2 {
pub x: f32,
pub y: f32,
}
Expand description
Point on 2D grid, the most frequently used geometric primitive.
Fields§
§x: f32
§y: f32
Implementations§
Source§impl Point2
impl Point2
Sourcepub fn towards(self, other: Self, offset: f32) -> Self
pub fn towards(self, other: Self, offset: f32) -> Self
Returns new point with offset towards other
on given distance.
Sourcepub fn towards_angle(self, angle: f32, offset: f32) -> Self
pub fn towards_angle(self, angle: f32, offset: f32) -> Self
Returns new point with offset towards given angle on given distance.
Sourcepub fn circle_intersection(self, other: Self, radius: f32) -> Option<[Self; 2]>
pub fn circle_intersection(self, other: Self, radius: f32) -> Option<[Self; 2]>
Returns points where circles with centers self
and other
,
and given radius intersect, or None
if they aren’t intersect.
Sourcepub fn len_squared(self) -> f32
pub fn len_squared(self) -> f32
Returns squared length of the vector.
Sourcepub fn neighbors4(self) -> [Self; 4]
pub fn neighbors4(self) -> [Self; 4]
Returns 4 closest neighbors of point.
Sourcepub fn neighbors4diagonal(self) -> [Self; 4]
pub fn neighbors4diagonal(self) -> [Self; 4]
Returns 4 closest diagonal neighbors of point.
Sourcepub fn neighbors8(self) -> [Self; 8]
pub fn neighbors8(self) -> [Self; 8]
Returns 8 closest neighbors of point.
Trait Implementations§
Source§impl AddAssign<f32> for Point2
impl AddAssign<f32> for Point2
Source§fn add_assign(&mut self, other: f32)
fn add_assign(&mut self, other: f32)
Performs the
+=
operation. Read moreSource§impl AddAssign for Point2
impl AddAssign for Point2
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+=
operation. Read moreSource§impl DivAssign<f32> for Point2
impl DivAssign<f32> for Point2
Source§fn div_assign(&mut self, other: f32)
fn div_assign(&mut self, other: f32)
Performs the
/=
operation. Read moreSource§impl DivAssign for Point2
impl DivAssign for Point2
Source§fn div_assign(&mut self, other: Self)
fn div_assign(&mut self, other: Self)
Performs the
/=
operation. Read moreSource§impl MulAssign<f32> for Point2
impl MulAssign<f32> for Point2
Source§fn mul_assign(&mut self, other: f32)
fn mul_assign(&mut self, other: f32)
Performs the
*=
operation. Read moreSource§impl MulAssign for Point2
impl MulAssign for Point2
Source§fn mul_assign(&mut self, other: Self)
fn mul_assign(&mut self, other: Self)
Performs the
*=
operation. Read moreSource§impl SubAssign<f32> for Point2
impl SubAssign<f32> for Point2
Source§fn sub_assign(&mut self, other: f32)
fn sub_assign(&mut self, other: f32)
Performs the
-=
operation. Read moreSource§impl SubAssign for Point2
impl SubAssign for Point2
Source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
Performs the
-=
operation. Read moreimpl Copy for Point2
impl Eq for Point2
Auto Trait Implementations§
impl Freeze for Point2
impl RefUnwindSafe for Point2
impl Send for Point2
impl Sync for Point2
impl Unpin for Point2
impl UnwindSafe for Point2
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Distance for T
impl<T> Distance for T
Source§fn distance_squared<P: Into<Point2>>(self, other: P) -> f32
fn distance_squared<P: Into<Point2>>(self, other: P) -> f32
Calculates squared euclidean distance from
self
to other
.Source§fn distance<P: Into<Point2>>(self, other: P) -> f32
fn distance<P: Into<Point2>>(self, other: P) -> f32
Calculates euclidean distance from
self
to other
.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.