From 9bc722778441d793e04844c2df1b4eccf80ece08 Mon Sep 17 00:00:00 2001 From: Ben Kuper Date: Mon, 28 Oct 2024 12:27:15 +0100 Subject: [PATCH 1/3] add extra operators and multiply/multiplied method to Vector3D --- modules/juce_opengl/geometry/juce_Vector3D.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/juce_opengl/geometry/juce_Vector3D.h b/modules/juce_opengl/geometry/juce_Vector3D.h index 75fe11315193..cca7ff44548e 100644 --- a/modules/juce_opengl/geometry/juce_Vector3D.h +++ b/modules/juce_opengl/geometry/juce_Vector3D.h @@ -57,17 +57,27 @@ class Vector3D /** Returns a vector that lies along the Z axis. */ static Vector3D zAxis() noexcept { return { 0, 0, (Type) 1 }; } - Vector3D& operator+= (Vector3D other) noexcept { x += other.x; y += other.y; z += other.z; return *this; } - Vector3D& operator-= (Vector3D other) noexcept { x -= other.x; y -= other.y; z -= other.z; return *this; } + Vector3D& operator+= (Type value) noexcept { x += value; y += value; z += value; return *this; } + Vector3D& operator-= (Type value) noexcept { x -= value; y -= value; z -= scaleFactor; return *this; } Vector3D& operator*= (Type scaleFactor) noexcept { x *= scaleFactor; y *= scaleFactor; z *= scaleFactor; return *this; } Vector3D& operator/= (Type scaleFactor) noexcept { x /= scaleFactor; y /= scaleFactor; z /= scaleFactor; return *this; } + Vector3D& operator+= (Vector3D other) noexcept { x += other.x; y += other.y; z += other.z; return *this; } + Vector3D& operator-= (Vector3D other) noexcept { x -= other.x; y -= other.y; z -= other.z; return *this; } + Vector3D& operator/= (Vector3D other) noexcept { x /= other.x; y /= other.y; z /= other.z; return *this; } - Vector3D operator+ (Vector3D other) const noexcept { return { x + other.x, y + other.y, z + other.z }; } - Vector3D operator- (Vector3D other) const noexcept { return { x - other.x, y - other.y, z - other.z }; } + Vector3D operator+ (Type value) const noexcept { return { x + value, y + value, z + value }; } + Vector3D operator- (Type value) const noexcept { return { x - value, y - value, z - value }; } Vector3D operator* (Type scaleFactor) const noexcept { return { x * scaleFactor, y * scaleFactor, z * scaleFactor }; } Vector3D operator/ (Type scaleFactor) const noexcept { return { x / scaleFactor, y / scaleFactor, z / scaleFactor }; } + Vector3D operator+ (Vector3D other) const noexcept { return { x + other.x, y + other.y, z + other.z }; } + Vector3D operator- (Vector3D other) const noexcept { return { x - other.x, y - other.y, z - other.z }; } + Vector3D operator/ (Vector3D other) const noexcept { return { x / other.x, y / other.y, z / other.z }; } Vector3D operator-() const noexcept { return { -x, -y, -z }; } + + Vector3D multiplied (Vector3D other) const noexcept { return { x * other.x, y * other.y, z * other.z }; } + void multiply(Vector3D other) const noexcept { x *= other.x; y *= other.y; z *= other.z } + /** Returns the dot-product of these two vectors. */ Type operator* (Vector3D other) const noexcept { return x * other.x + y * other.y + z * other.z; } From d06029f32d97e0d8a531be10e382b4c0d7899606 Mon Sep 17 00:00:00 2001 From: Ben Kuper Date: Wed, 30 Oct 2024 18:42:33 +0100 Subject: [PATCH 2/3] fix typo --- modules/juce_opengl/geometry/juce_Vector3D.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_opengl/geometry/juce_Vector3D.h b/modules/juce_opengl/geometry/juce_Vector3D.h index cca7ff44548e..c4d47c91fcff 100644 --- a/modules/juce_opengl/geometry/juce_Vector3D.h +++ b/modules/juce_opengl/geometry/juce_Vector3D.h @@ -58,7 +58,7 @@ class Vector3D static Vector3D zAxis() noexcept { return { 0, 0, (Type) 1 }; } Vector3D& operator+= (Type value) noexcept { x += value; y += value; z += value; return *this; } - Vector3D& operator-= (Type value) noexcept { x -= value; y -= value; z -= scaleFactor; return *this; } + Vector3D& operator-= (Type value) noexcept { x -= value; y -= value; z -= value; return *this; } Vector3D& operator*= (Type scaleFactor) noexcept { x *= scaleFactor; y *= scaleFactor; z *= scaleFactor; return *this; } Vector3D& operator/= (Type scaleFactor) noexcept { x /= scaleFactor; y /= scaleFactor; z /= scaleFactor; return *this; } Vector3D& operator+= (Vector3D other) noexcept { x += other.x; y += other.y; z += other.z; return *this; } From 065bf852435c485d8fba26fb963ffcafc297e87b Mon Sep 17 00:00:00 2001 From: Ben Kuper Date: Wed, 30 Oct 2024 19:09:35 +0100 Subject: [PATCH 3/3] fix typo --- modules/juce_opengl/geometry/juce_Vector3D.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_opengl/geometry/juce_Vector3D.h b/modules/juce_opengl/geometry/juce_Vector3D.h index c4d47c91fcff..9378d995edbf 100644 --- a/modules/juce_opengl/geometry/juce_Vector3D.h +++ b/modules/juce_opengl/geometry/juce_Vector3D.h @@ -76,7 +76,7 @@ class Vector3D Vector3D multiplied (Vector3D other) const noexcept { return { x * other.x, y * other.y, z * other.z }; } - void multiply(Vector3D other) const noexcept { x *= other.x; y *= other.y; z *= other.z } + void multiply(Vector3D other) const noexcept { x *= other.x; y *= other.y; z *= other.z; } /** Returns the dot-product of these two vectors. */ Type operator* (Vector3D other) const noexcept { return x * other.x + y * other.y + z * other.z; }