Struct buffer_graphics_lib::prelude::coord::Coord
source · pub struct Coord {
pub x: isize,
pub y: isize,
}
Expand description
Represents a 2D point
Supports basic math functions
§Usage
let point = coord!(10,10);
assert_eq!(point + coord!(1.0,1.0), coord!(11, 11));
assert_eq!(point / 2.0, coord!(5,5));
let pos: Coord = (2.0, 3.0).into();
assert_eq!(pos.neg(), coord!(-2, -3));
Fields§
§x: isize
§y: isize
Implementations§
source§impl Coord
impl Coord
sourcepub fn are_collinear<P1, P2>(self, b: P1, c: P2) -> bool
pub fn are_collinear<P1, P2>(self, b: P1, c: P2) -> bool
Returns true if self
, b
and c
are collinear (all on a straight line)
sourcepub fn is_between<P1, P2>(self, a: P1, b: P2) -> bool
pub fn is_between<P1, P2>(self, a: P1, b: P2) -> bool
Returns true if self
is on a line between a
and b
sourcepub fn mid_point<P>(self, rhs: P) -> Coord
pub fn mid_point<P>(self, rhs: P) -> Coord
Point midway in between self and rhs Use lerp for other positions
sourcepub fn angle_to<P>(self, rhs: P) -> isize
pub fn angle_to<P>(self, rhs: P) -> isize
Angle in degrees from self to rhs 0 is the top of the circle
pub fn cross_product<P>(self, rhs: P) -> isize
pub fn dot_product<P>(self, rhs: P) -> isize
sourcepub const fn perpendicular(self) -> Coord
pub const fn perpendicular(self) -> Coord
Returns a perpendicular point
Trait Implementations§
source§impl<'de> Deserialize<'de> for Coord
impl<'de> Deserialize<'de> for Coord
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Coord, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Coord, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Serialize for Coord
impl Serialize for Coord
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for Coord
impl Eq for Coord
impl StructuralPartialEq for Coord
Auto Trait Implementations§
impl Freeze for Coord
impl RefUnwindSafe for Coord
impl Send for Coord
impl Sync for Coord
impl Unpin for Coord
impl UnwindSafe for Coord
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)