From ba3f0aef8badc9c4e5c15f4e3cc49a9b64fe7b5a Mon Sep 17 00:00:00 2001 From: Vladimir Olteanu Date: Tue, 1 Jun 2021 08:39:45 +0300 Subject: [PATCH] Introduce Point::Absolute and Point::ManhattanDistance --- Source/engine.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/engine.h b/Source/engine.h index 246a56ec2..a5042a478 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -190,6 +190,18 @@ struct Point { return (approx + 512) / 1024; } + + Point Absolute() const + { + return { abs(x), abs(y) }; + } + + int ManhattanDistance(Point other) const + { + Point offset = (*this - other).Absolute(); + + return offset.x + offset.y; + } }; struct Size {