diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-09-21 23:40:30 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-09-21 23:43:31 +0800 |
commit | 6b78788d049c90dab3aec01d7bb7193f3927dc75 (patch) | |
tree | 977cfe754ccafb94e3e6743937d9132d2184df2f /include/cru/platform/GraphicsBase.h | |
parent | e31b0b8b37ae52e9402dc351e5fb0f361d30d0e0 (diff) | |
download | cru-geo-arc.tar.gz cru-geo-arc.tar.bz2 cru-geo-arc.zip |
HALF WORK!geo-arc
Diffstat (limited to 'include/cru/platform/GraphicsBase.h')
-rw-r--r-- | include/cru/platform/GraphicsBase.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/cru/platform/GraphicsBase.h b/include/cru/platform/GraphicsBase.h index b0f653ef..d9057beb 100644 --- a/include/cru/platform/GraphicsBase.h +++ b/include/cru/platform/GraphicsBase.h @@ -5,6 +5,7 @@ #include "cru/base/Range.h" #include "cru/base/String.h" +#include <cmath> #include <format> #include <limits> @@ -24,6 +25,11 @@ struct Point final { constexpr Point Negate() const { return Point(-x, -y); } + static constexpr float Distance(const Point& p1, const Point& p2) { + auto dx = p1.x - p2.x, dy = p1.y - p2.y; + return std::sqrt(dx * dx + dy * dy); + } + float x = 0; float y = 0; }; @@ -36,6 +42,10 @@ constexpr Point operator-(const Point& left, const Point& right) { return Point(left.x - right.x, left.y - right.y); } +constexpr Point operator/(const Point& point, float scale) { + return Point(point.x / scale, point.y / scale); +} + constexpr bool operator==(const Point& left, const Point& right) { return left.x == right.x && left.y == right.y; } |