From 28121d1b42fe15ec7d3e882d277e298117ec654e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Sun, 16 Feb 2025 01:04:21 +0100 Subject: [PATCH] Added component-wise min and max (cmin and cmax) --- GlitchyEngine/src/Math/Math.bf | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/GlitchyEngine/src/Math/Math.bf b/GlitchyEngine/src/Math/Math.bf index 4ee3676..81545ac 100644 --- a/GlitchyEngine/src/Math/Math.bf +++ b/GlitchyEngine/src/Math/Math.bf @@ -364,6 +364,40 @@ static } #endregion + +#region cmin / cmax + + public static float cmin(float2 v) + { + return Math.Min(v.X, v.Y); + } + + public static float cmin(float3 v) + { + return Math.Min(v.X, Math.Min(v.Y, v.Z)); + } + + public static float cmin(float4 v) + { + return Math.Min(v.X, Math.Min(v.Y, v.Z)); + } + + public static float cmax(float2 v) + { + return Math.Max(v.X, v.Y); + } + + public static float cmax(float3 v) + { + return Math.Max(v.X, Math.Max(v.Y, v.Z)); + } + + public static float cmax(float4 v) + { + return Math.Max(v.X, Math.Max(v.Y, v.Z)); + } + +#endregion #region exp, pow, log