diff --git a/Source/OpenTK/Math/Vector3.cs b/Source/OpenTK/Math/Vector3.cs index a25feaa9..37048fa7 100644 --- a/Source/OpenTK/Math/Vector3.cs +++ b/Source/OpenTK/Math/Vector3.cs @@ -398,67 +398,97 @@ namespace OpenTK.Math #endregion - #region Min + #region ComponentMin - /// - /// Calculate the component-wise minimum of two vectors - /// - /// First operand - /// Second operand - /// The component-wise minimum - public static Vector3 Min(Vector3 a, Vector3 b) - { - a.X = a.X < b.X ? a.X : b.X; - a.Y = a.Y < b.Y ? a.Y : b.Y; - a.Z = a.Z < b.Z ? a.Z : b.Z; - return a; - } + /// + /// Calculate the component-wise minimum of two vectors + /// + /// First operand + /// Second operand + /// The component-wise minimum + public static Vector3 ComponentMin(Vector3 a, Vector3 b) + { + a.X = a.X < b.X ? a.X : b.X; + a.Y = a.Y < b.Y ? a.Y : b.Y; + a.Z = a.Z < b.Z ? a.Z : b.Z; + return a; + } - /// - /// Calculate the component-wise minimum of two vectors - /// - /// First operand - /// Second operand - /// The component-wise minimum - public static void Min(ref Vector3 a, ref Vector3 b, out Vector3 result) - { - result.X = a.X < b.X ? a.X : b.X; - result.Y = a.Y < b.Y ? a.Y : b.Y; - result.Z = a.Z < b.Z ? a.Z : b.Z; - } + /// + /// Calculate the component-wise minimum of two vectors + /// + /// First operand + /// Second operand + /// The component-wise minimum + public static void ComponentMin(ref Vector3 a, ref Vector3 b, out Vector3 result) + { + result.X = a.X < b.X ? a.X : b.X; + result.Y = a.Y < b.Y ? a.Y : b.Y; + result.Z = a.Z < b.Z ? a.Z : b.Z; + } - #endregion + #endregion - #region Max + #region ComponentMax - /// - /// Calculate the component-wise maximum of two vectors - /// - /// First operand - /// Second operand - /// The component-wise maximum - public static Vector3 Max(Vector3 a, Vector3 b) - { - a.X = a.X > b.X ? a.X : b.X; - a.Y = a.Y > b.Y ? a.Y : b.Y; - a.Z = a.Z > b.Z ? a.Z : b.Z; - return a; - } + /// + /// Calculate the component-wise maximum of two vectors + /// + /// First operand + /// Second operand + /// The component-wise maximum + public static Vector3 ComponentMax(Vector3 a, Vector3 b) + { + a.X = a.X > b.X ? a.X : b.X; + a.Y = a.Y > b.Y ? a.Y : b.Y; + a.Z = a.Z > b.Z ? a.Z : b.Z; + return a; + } - /// - /// Calculate the component-wise maximum of two vectors - /// - /// First operand - /// Second operand - /// The component-wise maximum - public static void Max(ref Vector3 a, ref Vector3 b, out Vector3 result) - { - result.X = a.X > b.X ? a.X : b.X; - result.Y = a.Y > b.Y ? a.Y : b.Y; - result.Z = a.Z > b.Z ? a.Z : b.Z; - } + /// + /// Calculate the component-wise maximum of two vectors + /// + /// First operand + /// Second operand + /// The component-wise maximum + public static void ComponentMax(ref Vector3 a, ref Vector3 b, out Vector3 result) + { + result.X = a.X > b.X ? a.X : b.X; + result.Y = a.Y > b.Y ? a.Y : b.Y; + result.Z = a.Z > b.Z ? a.Z : b.Z; + } - #endregion + #endregion + + #region Min + + /// + /// Returns the Vector3 with the minimum magnitude + /// + /// Left operand + /// Right operand + /// The minimum Vector3 + public static Vector3 Min(Vector3 left, Vector3 right) + { + return left.LengthSquared < right.LengthSquared ? left : right; + } + + #endregion + + #region Max + + /// + /// Returns the Vector3 with the minimum magnitude + /// + /// Left operand + /// Right operand + /// The minimum Vector3 + public static Vector3 Max(Vector3 left, Vector3 right) + { + return left.LengthSquared >= right.LengthSquared ? left : right; + } + + #endregion #region Clamp