Expand description
Comprehensive 2 dimensional point implementation. This class is designed to work together
with the Grid
class.
A common theme in Advent of Code is operations in 2 dimensions. This module provides a
Point
struct along with implementations of several of the std::ops
traits to support
operator overloading, that allows shorthand expressions such as:
let a = Point::new(1, 2);
let b = Point::new(3, 4);
let k = 2;
assert_eq!(a + b, Point::new(4, 6));
assert_eq!(a - b, Point::new(-2, -2));
assert_eq!(a * k, Point::new(2, 4));
Additionally there are clockwise
and counter_clockwise
functions for 90 degree rotations
and a manhattan
function for the
Manhattan distance between 2 points.