com_croftsoft_core/math/geom/rectangle/
mod.rs

1// =============================================================================
2//! - Rectangle for the geometry module
3//!
4//! # Metadata
5//! - Copyright: © 2023 [`CroftSoft Inc`]
6//! - Author: [`David Wallace Croft`]
7//! - Created: 2023-03-18
8//! - Updated: 2023-03-18
9//!
10//! [`CroftSoft Inc`]: https://www.croftsoft.com/
11//! [`David Wallace Croft`]: https://www.croftsoft.com/people/david/
12// =============================================================================
13
14use super::point_2dd::Point2DD;
15
16#[cfg(test)]
17mod test;
18
19#[derive(Clone, Copy, Debug, Default)]
20pub struct Rectangle {
21  pub x_max: f64,
22  pub x_min: f64,
23  pub y_max: f64,
24  pub y_min: f64,
25}
26
27impl Rectangle {
28  pub fn contains(
29    &self,
30    point2dd: &Point2DD,
31  ) -> bool {
32    let Point2DD {
33      x,
34      y,
35    } = *point2dd;
36    x >= self.x_min && x <= self.x_max && y >= self.y_min && y <= self.y_max
37  }
38}