FR: Get the number of steps necessary to get from one coord to another
did:plc:zviscnpwyvj6y32agi5davn5 opened this 18d ago 2 comments
did:plc:zviscnpwyvj6y32agi5davn5 opened 18d ago
This should be available as HexCoord::steps_to(&self, other: HexCoord) -> usize. In cubic coordinates, we can find the distance like so:
q' = self.q - other.q
r' = self.r - other.r
s' = self.s - other.s
d = (|q'| + |r'| + |s'|) / 2With this, we should be able to get distance from the origin with something along the lines of:
impl HexCoord {
// ...
const fn length(&self) -> usize {
self.steps_to(HexCoord::ZERO)
}
}No activity yet.