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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// -----------------------------------------------------------------
// Simple cubic lattice trait
// -----------------------------------------------------------------
/*
#[derive(Copy, Clone, PartialEq)]
pub struct BC3(pub u32);
impl Iterator for BC3 {
type Item = Self;
fn next(&mut self) -> Option<Self::Item> {
let grid: u64 = self.0.into();
if grid != 0 {
let bit: u64 = grid.isolate_lowest_one();
*self = Self((grid ^ bit).try_into().unwrap());
Some(Self(bit.try_into().unwrap()))
} else {
None
}
}
}
impl LatticeCuboidCubicSimple for BC3 {
/// Easiest to visualize as a z-rotation, but same idea
fn rotate_x(&self) -> Self {
let mut cube = self.0;
// Swap vertical
swap_mask_shift_u32(&mut cube, 0o777_u32, 18);
// Swap main diagonal
swap_mask_shift_u32(&mut cube, 0o700_u32, 12);
// Swap outer diagonals
swap_mask_shift_u32(&mut cube, 0o700_070_u32, 6);
Self(cube)
}
fn shift_x(&self, shift: isize) -> Self {
match shift {
0 => Self(self.0),
1 => Self((self.0.unbounded_shl(1)) & 0o666_666_666_u32),
2 => Self((self.0.unbounded_shl(2)) & 0o444_444_444_u32),
-1 => Self((self.0.unbounded_shl(1)) & 0o333_333_333_u32),
-2 => Self((self.0.unbounded_shl(2)) & 0o111_111_111_u32),
_ => Self(0),
}
}
fn shift_y(&self, _shift: isize) -> Self {
todo!()
}
fn shift_z(&self, _shift: isize) -> Self {
todo!()
}
fn shift_xyz(&self, _shift: [isize; 3]) -> Self {
todo!()
}
}
*/