From b2d698472b4c52161b4b57b76266f8951cf5eef0 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Mon, 30 Nov 2020 10:00:15 +0330 Subject: [PATCH] LibGfx: Add a 'Point::absolute_relative_distance_to(Point)' This is significantly more elegant than subtracting the points and constructing another point from the abs() of their individual components. --- Libraries/LibGfx/Point.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Libraries/LibGfx/Point.h b/Libraries/LibGfx/Point.h index 6357b9d2b7..3860358ae7 100644 --- a/Libraries/LibGfx/Point.h +++ b/Libraries/LibGfx/Point.h @@ -208,6 +208,11 @@ public: return sqrtf(powf(m_x - other.m_x, 2.0f) + powf(m_y - other.m_y, 2.0f)); } + Point absolute_relative_distance_to(const Point& other) const + { + return { abs(dx_relative_to(other)), abs(dy_relative_to(other)) }; + } + template Point to_type() const {