Skip to main content

irox_geometry/
rectangle.rs

1// SPDX-License-Identifier: MIT
2// Copyright 2025 IROX Contributors
3//
4
5use crate::geometry::{Centroid, Geometry};
6use crate::{Point, Vector};
7use irox_tools::FloatIsh;
8
9#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Default)]
10pub struct Rectangle<T: FloatIsh> {
11    pub min: Point<T>,
12    pub size: Vector<T>,
13}
14
15impl<T: FloatIsh> Centroid<T> for Rectangle<T> {
16    fn centroid(&self) -> Point<T> {
17        self.min + self.size * T::from_f64(0.5)
18    }
19}
20
21impl<T: FloatIsh> Geometry<T> for Rectangle<T> {
22    fn contains(&self, _point: &Point<T>) -> bool {
23        todo!()
24    }
25
26    fn distance_to(&self, _point: &Point<T>) -> T {
27        todo!()
28    }
29
30    fn intersects(&self, _point: &Point<T>) -> bool {
31        todo!()
32    }
33
34    fn bounding_rectangle(&self) -> Rectangle<T> {
35        *self
36    }
37}