new coord stuff from 09

This commit is contained in:
Eric Mertens 2023-01-23 14:46:01 -06:00
parent a6d7a81ce1
commit e67df73b3a
2 changed files with 12 additions and 0 deletions

View File

@ -41,8 +41,16 @@ auto CCW(Coord) -> Coord;
auto Turn180(Coord) -> Coord;
/// @brief Computes the "1 norm" of a coordinate as a vector
/// @param vector
/// @return Sum of magnitudes of components
auto Norm1(Coord) -> std::int64_t;
/// @brief Computes the "infinity norm" of a coordinate as a vector
/// @param vector
/// @return Magnitude of the largest component
auto NormInf(Coord) -> std::int64_t;
/// Add two coordinates pairwise
auto operator+(Coord, Coord) -> Coord;

View File

@ -73,6 +73,10 @@ auto Norm1(Coord c) -> std::int64_t {
return std::abs(c.x) + std::abs(c.y);
}
auto NormInf(Coord c) -> std::int64_t {
return std::max(std::abs(c.x), std::abs(c.y));
}
auto operator+(Coord a, Coord b) -> Coord {
return {a.x + b.x, a.y + b.y};
}