pub struct Coord2D {
pub x: f64,
pub y: f64,
}Expand description
A 2D point in continuous space.
Coord2D represents a position. Subtracting two points yields a
CoordOffset (vector). Adding a vector to a point yields a new point.
use optic_core::*;
let a = Coord2D::from(100.0, 200.0);
let b = Coord2D::from(150.0, 180.0);
let d: CoordOffset = b - a;
let mid = a.lerp(b, 0.5);Implements Components<f64, 2>.
Fields§
§x: f64§y: f64Implementations§
Source§impl Coord2D
impl Coord2D
Sourcepub fn is_inside(&self, size: Size2D) -> bool
pub fn is_inside(&self, size: Size2D) -> bool
True if the point lies within the rectangle (0, 0) to (size.w, size.h).
Sourcepub fn distance_to(&self, other: Coord2D) -> f64
pub fn distance_to(&self, other: Coord2D) -> f64
Euclidean distance to another point.
Trait Implementations§
Source§impl Add<CoordOffset> for Coord2D
impl Add<CoordOffset> for Coord2D
Source§impl Components<f64, 2> for Coord2D
impl Components<f64, 2> for Coord2D
impl Copy for Coord2D
Auto Trait Implementations§
impl Freeze for Coord2D
impl RefUnwindSafe for Coord2D
impl Send for Coord2D
impl Sync for Coord2D
impl Unpin for Coord2D
impl UnsafeUnpin for Coord2D
impl UnwindSafe for Coord2D
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