spatial_decomposition/lib.rs
1//! This crate contains algorithms to decompose spatial sets into smaller subdomains.
2//! To this date, only `1D` and `2D` algorithms are implemented.
3//!
4//! ## Overview
5//! | Dim | Domain | Method | Paper |
6//! | --- | --- | --- | --- |
7//! | `2D` | [Rectangle] | [kong_mount_roscoe] | [Kong, Mount and Roscoe](https://scispace.com/pdf/the-decomposition-of-a-rectangle-into-rectangles-of-minimal-3whu99wjdy.pdf) |
8
9use approx_derive::RelativeEq;
10
11/// Generalized cuboid in `D` dimensions
12///
13/// ```
14/// use spatial_decomposition::*;
15/// use approx::assert_abs_diff_eq;
16///
17/// let c1 = Cuboid {
18/// min: [1.; 4],
19/// max: [15., 15., 10., 10.],
20/// };
21/// let c2 = Cuboid {
22/// min: [1.1; 4],
23/// max: [14.9, 14.99, 10.02, 9.97],
24/// };
25///
26/// assert_abs_diff_eq!(c1, c2, epsilon = 0.11);
27/// ```
28#[derive(Clone, Debug, PartialEq, RelativeEq)]
29#[approx(epsilon_type = F)]
30pub struct Cuboid<F, const D: usize> {
31 /// Lower bounds of cuboid
32 #[approx(into_iter)]
33 pub min: [F; D],
34 /// Upper bounds of cuboid
35 #[approx(into_iter)]
36 pub max: [F; D],
37}
38
39/// `2D` variant of the [Cuboid]
40pub type Rectangle<F> = Cuboid<F, 2>;
41
42/// `1D` variant of the [Cuboid]
43pub type Line<F> = Cuboid<F, 1>;
44
45mod kong_mount_roscoe;
46
47pub use kong_mount_roscoe::*;