condor_grid/point.rs
1//! Integer coordinates for discrete grid cells.
2//!
3//! [`Point`] is a zero-based `x`/`y` address whose bounds are defined by a concrete
4//! [`crate::Grid`]; loaders choose the visual origin, not solvers. Prefer
5//! [`condor_core::Point2`] for any-angle or continuous coordinates.
6
7/// A single grid cell address (`x` column, `y` row), zero-based.
8///
9/// Bounds are relative to a concrete [`crate::Grid`]; construction does not validate.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
11pub struct Point {
12 /// Column index (increasing to the right in standard maps).
13 pub x: usize,
14 /// Row index (increasing downward or upward depending only on map loaders).
15 pub y: usize,
16}
17
18impl Point {
19 /// Constructs a cell address without bounds checking against a grid.
20 #[must_use]
21 pub const fn new(x: usize, y: usize) -> Self {
22 Self { x, y }
23 }
24}
25
26impl From<(usize, usize)> for Point {
27 fn from((x, y): (usize, usize)) -> Self {
28 Self::new(x, y)
29 }
30}