From 53ed93d9095932ba9061f298e86964f177f5034b Mon Sep 17 00:00:00 2001 From: Jesse Buhagiar Date: Sat, 15 Jan 2022 13:01:08 +1100 Subject: [PATCH] LibGfx: Add unary `operator-()` to Vector2/3/4 --- Userland/Libraries/LibGfx/Vector2.h | 5 +++++ Userland/Libraries/LibGfx/Vector3.h | 5 +++++ Userland/Libraries/LibGfx/Vector4.h | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/Userland/Libraries/LibGfx/Vector2.h b/Userland/Libraries/LibGfx/Vector2.h index 2aa13136b2..43aa58df96 100644 --- a/Userland/Libraries/LibGfx/Vector2.h +++ b/Userland/Libraries/LibGfx/Vector2.h @@ -50,6 +50,11 @@ public: return Vector2(m_x - other.m_x, m_y - other.m_y); } + constexpr Vector2 operator-() const + { + return Vector2(-m_x, -m_y); + } + constexpr Vector2 operator*(const Vector2& other) const { return Vector2(m_x * other.m_x, m_y * other.m_y); diff --git a/Userland/Libraries/LibGfx/Vector3.h b/Userland/Libraries/LibGfx/Vector3.h index d6888c241e..6b7f4ae26d 100644 --- a/Userland/Libraries/LibGfx/Vector3.h +++ b/Userland/Libraries/LibGfx/Vector3.h @@ -55,6 +55,11 @@ public: return Vector3(m_x - other.m_x, m_y - other.m_y, m_z - other.m_z); } + constexpr Vector3 operator-() const + { + return Vector3(-m_x, -m_y, -m_z); + } + constexpr Vector3 operator*(const Vector3& other) const { return Vector3(m_x * other.m_x, m_y * other.m_y, m_z * other.m_z); diff --git a/Userland/Libraries/LibGfx/Vector4.h b/Userland/Libraries/LibGfx/Vector4.h index 06accb44a1..6f836939ba 100644 --- a/Userland/Libraries/LibGfx/Vector4.h +++ b/Userland/Libraries/LibGfx/Vector4.h @@ -60,6 +60,11 @@ public: return Vector4(m_x - other.m_x, m_y - other.m_y, m_z - other.m_z, m_w - other.m_w); } + constexpr Vector4 operator-() const + { + return Vector4(-m_x, -m_y, -m_z, -m_w); + } + constexpr Vector4 operator*(const Vector4& other) const { return Vector4(m_x * other.m_x, m_y * other.m_y, m_z * other.m_z, m_w * other.m_w);