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