From b3f9376dc8b0d8243c1ac80efe3d0c6e3d8ea8c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Sat, 30 Oct 2021 11:24:58 +0200 Subject: [PATCH] Added Min/Max to Vectors --- GlitchyEngine/src/Math/Vector2.bf | 14 ++++++++++++-- GlitchyEngine/src/Math/Vector3.bf | 10 ++++++++++ GlitchyEngine/src/Math/Vector4.bf | 10 ++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/GlitchyEngine/src/Math/Vector2.bf b/GlitchyEngine/src/Math/Vector2.bf index 0705248..c3d9517 100644 --- a/GlitchyEngine/src/Math/Vector2.bf +++ b/GlitchyEngine/src/Math/Vector2.bf @@ -133,7 +133,7 @@ namespace GlitchyEngine.Math /** * Calculates the projection of a onto b */ - public Vector2 Project(Vector2 a, Vector2 b) + public static Vector2 Project(Vector2 a, Vector2 b) { return (b * (Dot(a, b) / Dot(b, b))); } @@ -141,7 +141,7 @@ namespace GlitchyEngine.Math /** * Calculates the rejection of a from b */ - public Vector2 Reject(Vector2 a, Vector2 b) + public static Vector2 Reject(Vector2 a, Vector2 b) { return (a - b * (Dot(a, b) / Dot(b, b))); } @@ -159,6 +159,16 @@ namespace GlitchyEngine.Math return a + interpolationValue * (b - a); } + public static Vector2 Min(Vector2 a, Vector2 b) + { + return .(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y)); + } + + public static Vector2 Max(Vector2 a, Vector2 b) + { + return .(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y)); + } + // // Assignment operators // diff --git a/GlitchyEngine/src/Math/Vector3.bf b/GlitchyEngine/src/Math/Vector3.bf index 0f2e295..3b67c59 100644 --- a/GlitchyEngine/src/Math/Vector3.bf +++ b/GlitchyEngine/src/Math/Vector3.bf @@ -193,6 +193,16 @@ namespace GlitchyEngine.Math { return a + interpolationValue * (b - a); } + + public static Vector3 Min(Vector3 a, Vector3 b) + { + return .(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Min(a.Z, b.Z)); + } + + public static Vector3 Max(Vector3 a, Vector3 b) + { + return .(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y), Math.Min(a.Z, b.Z)); + } // // Assignment operators diff --git a/GlitchyEngine/src/Math/Vector4.bf b/GlitchyEngine/src/Math/Vector4.bf index 18bf9c8..1578a41 100644 --- a/GlitchyEngine/src/Math/Vector4.bf +++ b/GlitchyEngine/src/Math/Vector4.bf @@ -178,6 +178,16 @@ namespace GlitchyEngine.Math { return a + interpolationValue * (b - a); } + + public static Vector4 Min(Vector4 a, Vector4 b) + { + return .(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Min(a.Z, b.Z), Math.Min(a.W, b.W)); + } + + public static Vector4 Max(Vector4 a, Vector4 b) + { + return .(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y), Math.Min(a.Z, b.Z), Math.Min(a.W, b.W)); + } // // Assignment operators