#[derive(Clone, Copy, PartialEq, Debug, Default)]
pub struct Point {
#[allow(missing_docs)]
pub x: f64,
#[allow(missing_docs)]
pub y: f64,
}
impl From<(f64, f64)> for Point {
fn from((x, y): (f64, f64)) -> Self {
Self { x, y }
}
}
impl From<Point> for (f64, f64) {
fn from(Point { x, y }: Point) -> Self {
(x, y)
}
}
#[derive(Clone, Copy, PartialEq, Debug, Default)]
pub struct Circle {
pub radius: f64,
pub center: Point,
}
#[derive(Clone, Copy, PartialEq, Debug, Default)]
pub struct Arc {
pub a: Point,
pub b: Point,
pub center: Point,
}
impl std::fmt::Display for Point {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "({},{})", self.x, self.y)
}
}
impl Point {
pub fn euclidean_distance(&self, r: Point) -> f64 {
use crate::vector::V;
V::new(self.x, self.y).euclidean_distance(V::new(r.x, r.y))
}
}
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
pub enum Component {
X,
Y,
}