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