1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use From;
use IVec2;
/// A coordinate in the offset coordinate system.
///
/// Offset coordinates represent positions relative to a reference point (typically the origin at (0, 0)
/// in a 2D coordinate system, with the grid's left-bottom corner as origin). These coordinates indicate
/// displacement rather than absolute positions.
///
/// # Coordinate Ranges
///
/// `width` and `height` are the dimensions of the grid, and they define the valid ranges for the x and y coordinates:
///
/// - **Non-wrapped grid**:
/// `x ∈ [0, width)`, `y ∈ [0, height)`
///
/// - **Wrapped grid**:
/// - When x-wrapped: `x` can be any integer (multiple representations exist)
/// - When y-wrapped: `y` can be any integer (multiple representations exist)
///
/// # Multiple Representations
///
/// In wrapped grids, a single coordinate may have multiple representations. For example:
///
/// - If x-wrapped: (0, 0) ≡ (width, 0) ≡ (-width, 0) ≡ (2*width, 0), etc.
///
/// By convention, we typically store coordinates normalized to `x ∈ [0, width)` and `y ∈ [0, height)`.
/// If you want to convert a grid coordinate to a normalized offset coordinate, see [`Grid::normalize_offset`](crate::grid::Grid::normalize_offset).
;