projective_grid/
direction.rs1use serde::{Deserialize, Serialize};
2
3#[non_exhaustive]
5#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
6pub enum NeighborDirection {
7 Right,
8 Left,
9 Up,
10 Down,
11}
12
13impl NeighborDirection {
14 pub fn opposite(self) -> Self {
16 match self {
17 Self::Right => Self::Left,
18 Self::Left => Self::Right,
19 Self::Up => Self::Down,
20 Self::Down => Self::Up,
21 }
22 }
23
24 pub fn delta(self) -> (i32, i32) {
28 match self {
29 Self::Right => (1, 0),
30 Self::Left => (-1, 0),
31 Self::Up => (0, -1),
32 Self::Down => (0, 1),
33 }
34 }
35}
36
37#[derive(Debug)]
39pub struct NodeNeighbor {
40 pub direction: NeighborDirection,
42 pub index: usize,
44 pub distance: f32,
46 pub score: f32,
48}