From e87653ab47b428321e029b40f4dd00ecbd8877fd Mon Sep 17 00:00:00 2001 From: Leonetienne Date: Sun, 14 Dec 2025 21:59:22 +0100 Subject: [PATCH] implement unary negative on vectors --- MotionCore/Vector3d.cpp | 5 +++++ MotionCore/Vector3d.h | 1 + 2 files changed, 6 insertions(+) diff --git a/MotionCore/Vector3d.cpp b/MotionCore/Vector3d.cpp index b1b60fd..6f3c5ac 100755 --- a/MotionCore/Vector3d.cpp +++ b/MotionCore/Vector3d.cpp @@ -158,3 +158,8 @@ void Vector3d::normalize() noexcept y *= inv; z *= inv; } + +Vector3d Vector3d::operator-() const noexcept +{ + return Vector3d(-x, -y, -z); +} diff --git a/MotionCore/Vector3d.h b/MotionCore/Vector3d.h index 84ae078..e2d3bf6 100755 --- a/MotionCore/Vector3d.h +++ b/MotionCore/Vector3d.h @@ -24,6 +24,7 @@ public: Vector3d normalized() const noexcept; void normalize() noexcept; + Vector3d operator-() const noexcept; Vector3d& operator=(const Vector3d& other) noexcept; Vector3d& operator=(Vector3d&& other) noexcept;