diff --git a/src/OpenTK/Math/Vector2.cs b/src/OpenTK/Math/Vector2.cs
index d7f81427..b24f8d67 100644
--- a/src/OpenTK/Math/Vector2.cs
+++ b/src/OpenTK/Math/Vector2.cs
@@ -654,7 +654,7 @@ namespace OpenTK
#region ComponentMin
///
- /// Calculate the component-wise minimum of two vectors
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -667,7 +667,7 @@ namespace OpenTK
}
///
- /// Calculate the component-wise minimum of two vectors
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -683,7 +683,7 @@ namespace OpenTK
#region ComponentMax
///
- /// Calculate the component-wise maximum of two vectors
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -696,7 +696,7 @@ namespace OpenTK
}
///
- /// Calculate the component-wise maximum of two vectors
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -709,6 +709,64 @@ namespace OpenTK
#endregion
+ #region MagnitudeMin
+
+ ///
+ /// Returns the Vector2 with the minimum magnitude. If the magnitudes are equal, the second vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The minimum Vector2
+ public static Vector2 MagnitudeMin(Vector2 left, Vector2 right)
+ {
+ return left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector2 with the minimum magnitude. If the magnitudes are equal, the second vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise minimum
+ /// The minimum Vector2
+ public static void MagnitudeMin(ref Vector2 left, ref Vector2 right, out Vector2 result)
+ {
+ result = left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
+ #region MagnitudeMax
+
+ ///
+ /// Returns the Vector2 with the maximum magnitude. If the magnitudes are equal, the first vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The maximum Vector2
+ public static Vector2 MagnitudeMax(Vector2 left, Vector2 right)
+ {
+ return left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector2 with the maximum magnitude. If the magnitudes are equal, the first vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise maximum
+ /// The maximum Vector2
+ public static void MagnitudeMax(ref Vector2 left, ref Vector2 right, out Vector2 result)
+ {
+ result = left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
#region Min
///
@@ -717,6 +775,7 @@ namespace OpenTK
/// Left operand
/// Right operand
/// The minimum Vector3
+ [Obsolete("Use MagnitudeMin() instead.")]
public static Vector2 Min(Vector2 left, Vector2 right)
{
return left.LengthSquared < right.LengthSquared ? left : right;
@@ -732,6 +791,7 @@ namespace OpenTK
/// Left operand
/// Right operand
/// The minimum Vector3
+ [Obsolete("Use MagnitudeMax() instead.")]
public static Vector2 Max(Vector2 left, Vector2 right)
{
return left.LengthSquared >= right.LengthSquared ? left : right;
@@ -1074,7 +1134,7 @@ namespace OpenTK
vec.Y *= scale.Y;
return vec;
}
-
+
///
/// Divides the specified instance by a scalar.
///
diff --git a/src/OpenTK/Math/Vector2d.cs b/src/OpenTK/Math/Vector2d.cs
index 3993aafa..069ac10c 100644
--- a/src/OpenTK/Math/Vector2d.cs
+++ b/src/OpenTK/Math/Vector2d.cs
@@ -577,6 +577,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise minimum
+ [Obsolete("Use ComponentMin() instead.")]
public static Vector2d Min(Vector2d a, Vector2d b)
{
a.X = a.X < b.X ? a.X : b.X;
@@ -590,6 +591,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise minimum
+ [Obsolete("Use ComponentMin() instead.")]
public static void Min(ref Vector2d a, ref Vector2d b, out Vector2d result)
{
result.X = a.X < b.X ? a.X : b.X;
@@ -606,6 +608,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise maximum
+ [Obsolete("Use ComponentMax() instead.")]
public static Vector2d Max(Vector2d a, Vector2d b)
{
a.X = a.X > b.X ? a.X : b.X;
@@ -619,6 +622,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise maximum
+ [Obsolete("Use ComponentMax() instead.")]
public static void Max(ref Vector2d a, ref Vector2d b, out Vector2d result)
{
result.X = a.X > b.X ? a.X : b.X;
@@ -627,6 +631,122 @@ namespace OpenTK
#endregion
+ #region ComponentMin
+
+ ///
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise minimum
+ public static Vector2d ComponentMin(Vector2d a, Vector2d b)
+ {
+ a.X = a.X < b.X ? a.X : b.X;
+ a.Y = a.Y < b.Y ? a.Y : b.Y;
+ return a;
+ }
+
+ ///
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise minimum
+ public static void ComponentMin(ref Vector2d a, ref Vector2d b, out Vector2d result)
+ {
+ result.X = a.X < b.X ? a.X : b.X;
+ result.Y = a.Y < b.Y ? a.Y : b.Y;
+ }
+
+ #endregion
+
+ #region ComponentMax
+
+ ///
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise maximum
+ public static Vector2d ComponentMax(Vector2d a, Vector2d b)
+ {
+ a.X = a.X > b.X ? a.X : b.X;
+ a.Y = a.Y > b.Y ? a.Y : b.Y;
+ return a;
+ }
+
+ ///
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise maximum
+ public static void ComponentMax(ref Vector2d a, ref Vector2d b, out Vector2d result)
+ {
+ result.X = a.X > b.X ? a.X : b.X;
+ result.Y = a.Y > b.Y ? a.Y : b.Y;
+ }
+
+ #endregion
+
+ #region MagnitudeMin
+
+ ///
+ /// Returns the Vector2d with the minimum magnitude. If the magnitudes are equal, the second vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The minimum Vector2d
+ public static Vector2d MagnitudeMin(Vector2d left, Vector2d right)
+ {
+ return left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector2d with the minimum magnitude. If the magnitudes are equal, the second vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise minimum
+ /// The minimum Vector2d
+ public static void MagnitudeMin(ref Vector2d left, ref Vector2d right, out Vector2d result)
+ {
+ result = left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
+ #region MagnitudeMax
+
+ ///
+ /// Returns the Vector2d with the minimum magnitude. If the magnitudes are equal, the first vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The minimum Vector2d
+ public static Vector2d MagnitudeMax(Vector2d left, Vector2d right)
+ {
+ return left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector2d with the maximum magnitude. If the magnitudes are equal, the first vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise maximum
+ /// The maximum Vector2d
+ public static void MagnitudeMax(ref Vector2d left, ref Vector2d right, out Vector2d result)
+ {
+ result = left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
#region Clamp
///
@@ -936,7 +1056,7 @@ namespace OpenTK
vec.Y *= scale.Y;
return vec;
}
-
+
///
/// Divides an instance by a scalar.
///
diff --git a/src/OpenTK/Math/Vector3.cs b/src/OpenTK/Math/Vector3.cs
index 000a3698..e0abc54e 100644
--- a/src/OpenTK/Math/Vector3.cs
+++ b/src/OpenTK/Math/Vector3.cs
@@ -660,7 +660,7 @@ namespace OpenTK
#region ComponentMin
///
- /// Calculate the component-wise minimum of two vectors
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -674,7 +674,7 @@ namespace OpenTK
}
///
- /// Calculate the component-wise minimum of two vectors
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -691,7 +691,7 @@ namespace OpenTK
#region ComponentMax
///
- /// Calculate the component-wise maximum of two vectors
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -705,7 +705,7 @@ namespace OpenTK
}
///
- /// Calculate the component-wise maximum of two vectors
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -719,6 +719,64 @@ namespace OpenTK
#endregion
+ #region MagnitudeMin
+
+ ///
+ /// Returns the Vector3 with the minimum magnitude. If the magnitudes are equal, the second vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The minimum Vector3
+ public static Vector3 MagnitudeMin(Vector3 left, Vector3 right)
+ {
+ return left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector3 with the minimum magnitude. If the magnitudes are equal, the second vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise minimum
+ /// The minimum Vector3
+ public static void MagnitudeMin(ref Vector3 left, ref Vector3 right, out Vector3 result)
+ {
+ result = left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
+ #region MagnitudeMax
+
+ ///
+ /// Returns the Vector3 with the maximum magnitude. If the magnitudes are equal, the first vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The maximum Vector3
+ public static Vector3 MagnitudeMax(Vector3 left, Vector3 right)
+ {
+ return left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector3 with the maximum magnitude. If the magnitudes are equal, the first vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise maximum
+ /// The maximum Vector3
+ public static void MagnitudeMax(ref Vector3 left, ref Vector3 right, out Vector3 result)
+ {
+ result = left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
#region Min
///
@@ -727,6 +785,7 @@ namespace OpenTK
/// Left operand
/// Right operand
/// The minimum Vector3
+ [Obsolete("Use MagnitudeMin() instead.")]
public static Vector3 Min(Vector3 left, Vector3 right)
{
return left.LengthSquared < right.LengthSquared ? left : right;
@@ -742,6 +801,7 @@ namespace OpenTK
/// Left operand
/// Right operand
/// The minimum Vector3
+ [Obsolete("Use MagnitudeMax() instead.")]
public static Vector3 Max(Vector3 left, Vector3 right)
{
return left.LengthSquared >= right.LengthSquared ? left : right;
@@ -1270,10 +1330,10 @@ namespace OpenTK
{
Vector4 result;
- result.X =
- vector.X * worldViewProjection.M11 +
- vector.Y * worldViewProjection.M21 +
- vector.Z * worldViewProjection.M31 +
+ result.X =
+ vector.X * worldViewProjection.M11 +
+ vector.Y * worldViewProjection.M21 +
+ vector.Z * worldViewProjection.M31 +
worldViewProjection.M41;
result.Y =
diff --git a/src/OpenTK/Math/Vector3d.cs b/src/OpenTK/Math/Vector3d.cs
index 556b9ab9..0be7f1c9 100644
--- a/src/OpenTK/Math/Vector3d.cs
+++ b/src/OpenTK/Math/Vector3d.cs
@@ -658,7 +658,7 @@ namespace OpenTK
#region ComponentMin
///
- /// Calculate the component-wise minimum of two vectors
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -672,7 +672,7 @@ namespace OpenTK
}
///
- /// Calculate the component-wise minimum of two vectors
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -689,7 +689,7 @@ namespace OpenTK
#region ComponentMax
///
- /// Calculate the component-wise maximum of two vectors
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -703,7 +703,7 @@ namespace OpenTK
}
///
- /// Calculate the component-wise maximum of two vectors
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
///
/// First operand
/// Second operand
@@ -717,6 +717,60 @@ namespace OpenTK
#endregion
+ #region MagnitudeMin
+
+ ///
+ /// Returns the Vector3d with the minimum magnitude
+ ///
+ /// Left operand
+ /// Right operand
+ /// The minimum Vector3d
+ public static Vector3d MagnitudeMin(Vector3d left, Vector3d right)
+ {
+ return left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector3d with the minimum magnitude
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise minimum
+ /// The minimum Vector3d
+ public static void MagnitudeMin(ref Vector3d left, ref Vector3d right, out Vector3d result)
+ {
+ result = left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
+ #region MagnitudeMax
+
+ ///
+ /// Returns the Vector3d with the minimum magnitude
+ ///
+ /// Left operand
+ /// Right operand
+ /// The minimum Vector3d
+ public static Vector3d MagnitudeMax(Vector3d left, Vector3d right)
+ {
+ return left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector3d with the maximum magnitude
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise maximum
+ /// The maximum Vector3d
+ public static void MagnitudeMax(ref Vector3d left, ref Vector3d right, out Vector3d result)
+ {
+ result = left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
#region Min
///
@@ -725,6 +779,7 @@ namespace OpenTK
/// Left operand
/// Right operand
/// The minimum Vector3
+ [Obsolete("Use MagnitudeMin() instead.")]
public static Vector3d Min(Vector3d left, Vector3d right)
{
return left.LengthSquared < right.LengthSquared ? left : right;
@@ -740,6 +795,7 @@ namespace OpenTK
/// Left operand
/// Right operand
/// The minimum Vector3
+ [Obsolete("Use MagnitudeMax() instead.")]
public static Vector3d Max(Vector3d left, Vector3d right)
{
return left.LengthSquared >= right.LengthSquared ? left : right;
@@ -1372,7 +1428,7 @@ namespace OpenTK
vec.Z *= scale;
return vec;
}
-
+
///
/// Component-wise multiplication between the specified instance by a scale vector.
///
@@ -1386,7 +1442,7 @@ namespace OpenTK
vec.Z *= scale.Z;
return vec;
}
-
+
///
/// Divides an instance by a scalar.
///
diff --git a/src/OpenTK/Math/Vector4.cs b/src/OpenTK/Math/Vector4.cs
index 2d876544..b2d0ea55 100644
--- a/src/OpenTK/Math/Vector4.cs
+++ b/src/OpenTK/Math/Vector4.cs
@@ -703,6 +703,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise minimum
+ [Obsolete("Use ComponentMin() instead.")]
public static Vector4 Min(Vector4 a, Vector4 b)
{
a.X = a.X < b.X ? a.X : b.X;
@@ -718,6 +719,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise minimum
+ [Obsolete("Use ComponentMin() instead.")]
public static void Min(ref Vector4 a, ref Vector4 b, out Vector4 result)
{
result.X = a.X < b.X ? a.X : b.X;
@@ -736,6 +738,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise maximum
+ [Obsolete("Use ComponentMax() instead.")]
public static Vector4 Max(Vector4 a, Vector4 b)
{
a.X = a.X > b.X ? a.X : b.X;
@@ -751,6 +754,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise maximum
+ [Obsolete("Use ComponentMax() instead.")]
public static void Max(ref Vector4 a, ref Vector4 b, out Vector4 result)
{
result.X = a.X > b.X ? a.X : b.X;
@@ -761,6 +765,130 @@ namespace OpenTK
#endregion
+ #region ComponentMin
+
+ ///
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise minimum
+ public static Vector4 ComponentMin(Vector4 a, Vector4 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;
+ a.W = a.W < b.W ? a.W : b.W;
+ return a;
+ }
+
+ ///
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise minimum
+ public static void ComponentMin(ref Vector4 a, ref Vector4 b, out Vector4 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;
+ result.W = a.W < b.W ? a.W : b.W;
+ }
+
+ #endregion
+
+ #region ComponentMax
+
+ ///
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise maximum
+ public static Vector4 ComponentMax(Vector4 a, Vector4 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;
+ a.W = a.W > b.W ? a.W : b.W;
+ return a;
+ }
+
+ ///
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise maximum
+ public static void ComponentMax(ref Vector4 a, ref Vector4 b, out Vector4 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;
+ result.W = a.W > b.W ? a.W : b.W;
+ }
+
+ #endregion
+
+ #region MagnitudeMin
+
+ ///
+ /// Returns the Vector4 with the minimum magnitude. If the magnitudes are equal, the second vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The minimum Vector4
+ public static Vector4 MagnitudeMin(Vector4 left, Vector4 right)
+ {
+ return left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector4 with the minimum magnitude. If the magnitudes are equal, the second vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise minimum
+ /// The minimum Vector4
+ public static void MagnitudeMin(ref Vector4 left, ref Vector4 right, out Vector4 result)
+ {
+ result = left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
+ #region MagnitudeMax
+
+ ///
+ /// Returns the Vector4 with the maximum magnitude. If the magnitudes are equal, the first vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The maximum Vector4
+ public static Vector4 MagnitudeMax(Vector4 left, Vector4 right)
+ {
+ return left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector4 with the maximum magnitude. If the magnitudes are equal, the first vector
+ /// is selected.
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise maximum
+ /// The maximum Vector4
+ public static void MagnitudeMax(ref Vector4 left, ref Vector4 right, out Vector4 result)
+ {
+ result = left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
#region Clamp
///
@@ -1514,7 +1642,7 @@ namespace OpenTK
vec.W *= scale;
return vec;
}
-
+
///
/// Component-wise multiplication between the specified instance by a scale vector.
///
diff --git a/src/OpenTK/Math/Vector4d.cs b/src/OpenTK/Math/Vector4d.cs
index facc329d..67a4af8b 100644
--- a/src/OpenTK/Math/Vector4d.cs
+++ b/src/OpenTK/Math/Vector4d.cs
@@ -175,7 +175,7 @@ namespace OpenTK
#endregion
#region Public Members
-
+
///
/// Gets or sets the value at the index of the Vector.
///
@@ -705,6 +705,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise minimum
+ [Obsolete("Use ComponentMin() instead.")]
public static Vector4d Min(Vector4d a, Vector4d b)
{
a.X = a.X < b.X ? a.X : b.X;
@@ -720,6 +721,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise minimum
+ [Obsolete("Use ComponentMin() instead.")]
public static void Min(ref Vector4d a, ref Vector4d b, out Vector4d result)
{
result.X = a.X < b.X ? a.X : b.X;
@@ -738,6 +740,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise maximum
+ [Obsolete("Use ComponentMax() instead.")]
public static Vector4d Max(Vector4d a, Vector4d b)
{
a.X = a.X > b.X ? a.X : b.X;
@@ -753,6 +756,7 @@ namespace OpenTK
/// First operand
/// Second operand
/// The component-wise maximum
+ [Obsolete("Use ComponentMax() instead.")]
public static void Max(ref Vector4d a, ref Vector4d b, out Vector4d result)
{
result.X = a.X > b.X ? a.X : b.X;
@@ -763,6 +767,126 @@ namespace OpenTK
#endregion
+ #region ComponentMin
+
+ ///
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise minimum
+ public static Vector4d ComponentMin(Vector4d a, Vector4d 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;
+ a.W = a.W < b.W ? a.W : b.W;
+ return a;
+ }
+
+ ///
+ /// Returns a vector created from the smallest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise minimum
+ public static void ComponentMin(ref Vector4d a, ref Vector4d b, out Vector4d 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;
+ result.W = a.W < b.W ? a.W : b.W;
+ }
+
+ #endregion
+
+ #region ComponentMax
+
+ ///
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise maximum
+ public static Vector4d ComponentMax(Vector4d a, Vector4d 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;
+ a.W = a.W > b.W ? a.W : b.W;
+ return a;
+ }
+
+ ///
+ /// Returns a vector created from the largest of the corresponding components of the given vectors.
+ ///
+ /// First operand
+ /// Second operand
+ /// The component-wise maximum
+ public static void ComponentMax(ref Vector4d a, ref Vector4d b, out Vector4d 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;
+ result.W = a.W > b.W ? a.W : b.W;
+ }
+
+ #endregion
+
+ #region MagnitudeMin
+
+ ///
+ /// Returns the Vector4d with the minimum magnitude
+ ///
+ /// Left operand
+ /// Right operand
+ /// The minimum Vector4d
+ public static Vector4d MagnitudeMin(Vector4d left, Vector4d right)
+ {
+ return left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector4d with the minimum magnitude
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise minimum
+ /// The minimum Vector4d
+ public static void MagnitudeMin(ref Vector4d left, ref Vector4d right, out Vector4d result)
+ {
+ result = left.LengthSquared < right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
+ #region MagnitudeMax
+
+ ///
+ /// Returns the Vector4d with the minimum magnitude
+ ///
+ /// Left operand
+ /// Right operand
+ /// The minimum Vector4d
+ public static Vector4d MagnitudeMax(Vector4d left, Vector4d right)
+ {
+ return left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ ///
+ /// Returns the Vector4d with the maximum magnitude
+ ///
+ /// Left operand
+ /// Right operand
+ /// The magnitude-wise maximum
+ /// The maximum Vector4d
+ public static void MagnitudeMax(ref Vector4d left, ref Vector4d right, out Vector4d result)
+ {
+ result = left.LengthSquared >= right.LengthSquared ? left : right;
+ }
+
+ #endregion
+
#region Clamp
///
@@ -1493,7 +1617,7 @@ namespace OpenTK
vec.W *= scale;
return vec;
}
-
+
///
/// Component-wise multiplication between the specified instance by a scale vector.
///
diff --git a/tests/OpenTK.Tests/Assertions.fs b/tests/OpenTK.Tests/Assertions.fs
index f47e7ee1..b6fdfc8e 100644
--- a/tests/OpenTK.Tests/Assertions.fs
+++ b/tests/OpenTK.Tests/Assertions.fs
@@ -9,7 +9,7 @@ open OpenTK
[]
module private AssertHelpers =
[]
- let private BitAccuracy = 9
+ let private BitAccuracy = 13
let approxEq a b = MathHelper.ApproximatelyEqual(a,b,BitAccuracy)
diff --git a/tests/OpenTK.Tests/Generators.fs b/tests/OpenTK.Tests/Generators.fs
index cbcdd929..39200f5b 100644
--- a/tests/OpenTK.Tests/Generators.fs
+++ b/tests/OpenTK.Tests/Generators.fs
@@ -22,18 +22,21 @@ module private Generators =
singleArb
|> Gen.two
|> Gen.map Vector2
+ |> Gen.filter (fun v -> not <| (Single.IsNaN v.Length || Single.IsInfinity v.Length ))
|> Arb.fromGen
let vec3 =
singleArb
|> Gen.three
|> Gen.map Vector3
+ |> Gen.filter (fun v -> not <| (Single.IsNaN v.Length || Single.IsInfinity v.Length ))
|> Arb.fromGen
let vec4 =
singleArb
|> Gen.four
|> Gen.map Vector4
+ |> Gen.filter (fun v -> not <| (Single.IsNaN v.Length || Single.IsInfinity v.Length ))
|> Arb.fromGen
let quat =
diff --git a/tests/OpenTK.Tests/Vector2Tests.fs b/tests/OpenTK.Tests/Vector2Tests.fs
index 724bc553..f9e741e3 100644
--- a/tests/OpenTK.Tests/Vector2Tests.fs
+++ b/tests/OpenTK.Tests/Vector2Tests.fs
@@ -462,94 +462,99 @@ module Vector2 =
Assert.ApproximatelyEqual(norm, Vector2.NormalizeFast(a));
+ [ |])>]
+ module ``Magnitude min and max`` =
+ //
+ []
+ let ``MagnitudeMin selects the vector with equal or lesser magnitude given two vectors`` (v1 : Vector2, v2: Vector2) =
+ let l1 = v1.LengthSquared
+ let l2 = v2.LengthSquared
+
+ let vMin = Vector2.MagnitudeMin(v1, v2)
+
+ if vMin = v1 then
+ let v1ShorterThanv2 = l1 < l2
+ Assert.True(v1ShorterThanv2)
+ else
+ let v2ShorterThanOrEqualTov1 = l2 <= l1
+ Assert.True(v2ShorterThanOrEqualTov1)
+
+ []
+ let ``MagnitudeMax selects the vector with equal or greater magnitude given two vectors`` (v1 : Vector2, v2: Vector2) =
+ let l1 = v1.LengthSquared
+ let l2 = v2.LengthSquared
+
+ let vMin = Vector2.MagnitudeMax(v1, v2)
+
+ if vMin = v1 then
+ let v1LongerThanOrEqualTov2 = l1 >= l2
+ Assert.True(v1LongerThanOrEqualTov2)
+ else
+ let v2LongerThanv1 = l2 > l1
+ Assert.True(v2LongerThanv1)
+
+ []
+ let ``MagnitudeMin by reference selects the vector with equal or lesser magnitude given two vectors`` (v1 : Vector2, v2: Vector2) =
+ let l1 = v1.LengthSquared
+ let l2 = v2.LengthSquared
+
+ let vMin = Vector2.MagnitudeMin(ref v1, ref v2)
+
+ if vMin = v1 then
+ let v1ShorterThanv2 = l1 < l2
+ Assert.True(v1ShorterThanv2)
+ else
+ let v2ShorterThanOrEqualTov1 = l2 <= l1
+ Assert.True(v2ShorterThanOrEqualTov1)
+
+ []
+ let ``MagnitudeMax by reference selects the vector with equal greater magnitude given two vectors`` (v1 : Vector2, v2: Vector2) =
+ let l1 = v1.LengthSquared
+ let l2 = v2.LengthSquared
+
+ let vMin = Vector2.MagnitudeMax(ref v1, ref v2)
+
+ if vMin = v1 then
+ let v1LongerThanOrEqualTov2 = l1 >= l2
+ Assert.True(v1LongerThanOrEqualTov2)
+ else
+ let v2LongerThanv1 = l2 > l1
+ Assert.True(v2LongerThanv1)
+
[ |])>]
module ``Component min and max`` =
//
[]
- let ``ComponentMin produces a new vector from the smallest components of the given vectors`` (x, y, u, w) =
- let v1 = Vector2(x, y)
- let v2 = Vector2(u, w)
-
+ let ``ComponentMin creates a new vector from the smallest components of given vectors`` (v1 : Vector2, v2: Vector2) =
let vMin = Vector2.ComponentMin(v1, v2)
+ let isComponentSmallest smallComp comp1 comp2 = smallComp <= comp1 && smallComp <= comp2
- Assert.True(vMin.X <= v1.X)
- Assert.True(vMin.X <= v2.X)
-
- Assert.True(vMin.Y <= v1.Y)
- Assert.True(vMin.Y <= v2.Y)
+ Assert.True(isComponentSmallest vMin.X v1.X v2.X)
+ Assert.True(isComponentSmallest vMin.Y v1.Y v2.Y)
[]
- let ``ComponentMax produces a new vector from the largest components of the given vectors`` (x, y, u, w) =
- let v1 = Vector2(x, y)
- let v2 = Vector2(u, w)
-
+ let ``ComponentMax creates a new vector from the greatest components of given vectors`` (v1 : Vector2, v2: Vector2) =
let vMax = Vector2.ComponentMax(v1, v2)
+ let isComponentLargest largeComp comp1 comp2 = largeComp >= comp1 && largeComp >= comp2
- Assert.True(vMax.X >= v1.X)
- Assert.True(vMax.X >= v2.X)
-
- Assert.True(vMax.Y >= v1.Y)
- Assert.True(vMax.Y >= v2.Y)
+ Assert.True(isComponentLargest vMax.X v1.X v2.X)
+ Assert.True(isComponentLargest vMax.Y v1.Y v2.Y)
[]
- let ``ComponentMin by reference produces a new vector from the smallest components of the given vectors`` (x, y, u, w) =
- let v1 = Vector2(x, y)
- let v2 = Vector2(u, w)
-
+ let ``ComponentMin by reference creates a new vector from the smallest components of given vectors`` (v1 : Vector2, v2: Vector2) =
let vMin = Vector2.ComponentMin(ref v1, ref v2)
+ let isComponentSmallest smallComp comp1 comp2 = smallComp <= comp1 && smallComp <= comp2
- Assert.True(vMin.X <= v1.X)
- Assert.True(vMin.X <= v2.X)
-
- Assert.True(vMin.Y <= v1.Y)
- Assert.True(vMin.Y <= v2.Y)
+ Assert.True(isComponentSmallest vMin.X v1.X v2.X)
+ Assert.True(isComponentSmallest vMin.Y v1.Y v2.Y)
[]
- let ``ComponentMax by reference produces a new vector from the largest components of the given vectors`` (x, y, u, w) =
- let v1 = Vector2(x, y)
- let v2 = Vector2(u, w)
-
+ let ``ComponentMax by reference creates a new vector from the greatest components of given vectors`` (v1 : Vector2, v2: Vector2) =
let vMax = Vector2.ComponentMax(ref v1, ref v2)
+ let isComponentLargest largeComp comp1 comp2 = largeComp >= comp1 && largeComp >= comp2
- Assert.True(vMax.X >= v1.X)
- Assert.True(vMax.X >= v2.X)
-
- Assert.True(vMax.Y >= v1.Y)
- Assert.True(vMax.Y >= v2.Y)
-
- []
- let ``Min selects the vector with lesser magnitude given two vectors`` (x, y, u, w) =
- let v1 = Vector2(x, y)
- let v2 = Vector2(u, w)
-
- let l1 = v1.LengthSquared
- let l2 = v2.LengthSquared
-
- let vMin = Vector2.Min(v1, v2)
-
- if l1 < l2 then
- let equalsFirst = vMin = v1
- Assert.True(equalsFirst)
- else
- let equalsLast = vMin = v2
- Assert.True(equalsLast)
-
- []
- let ``Max selects the vector with greater magnitude given two vectors`` (x, y, u, w) =
- let v1 = Vector2(x, y)
- let v2 = Vector2(u, w)
-
- let l1 = v1.LengthSquared
- let l2 = v2.LengthSquared
-
- let vMin = Vector2.Max(v1, v2)
-
- if l1 >= l2 then
- let equalsFirst = vMin = v1
- Assert.True(equalsFirst)
- else
- let equalsLast = vMin = v2
- Assert.True(equalsLast)
+ Assert.True(isComponentLargest vMax.X v1.X v2.X)
+ Assert.True(isComponentLargest vMax.Y v1.Y v2.Y)
[ |])>]
module Transformation =
diff --git a/tests/OpenTK.Tests/Vector3Tests.fs b/tests/OpenTK.Tests/Vector3Tests.fs
index 9f89ba48..8987c9f7 100644
--- a/tests/OpenTK.Tests/Vector3Tests.fs
+++ b/tests/OpenTK.Tests/Vector3Tests.fs
@@ -527,106 +527,103 @@ module Vector3 =
let vRes = Vector3.Cross(ref a, ref b)
Assert.Equal(cross, vRes)
+ [ |])>]
+ module ``Magnitude min and max`` =
+ //
+ []
+ let ``MagnitudeMin selects the vector with equal or lesser magnitude given two vectors`` (v1 : Vector3, v2: Vector3) =
+ let l1 = v1.LengthSquared
+ let l2 = v2.LengthSquared
+
+ let vMin = Vector3.MagnitudeMin(v1, v2)
+
+ if vMin = v1 then
+ let v1ShorterThanv2 = l1 < l2
+ Assert.True(v1ShorterThanv2)
+ else
+ let v2ShorterThanOrEqualTov1 = l2 <= l1
+ Assert.True(v2ShorterThanOrEqualTov1)
+
+ []
+ let ``MagnitudeMax selects the vector with equal or greater magnitude given two vectors`` (v1 : Vector3, v2: Vector3) =
+ let l1 = v1.LengthSquared
+ let l2 = v2.LengthSquared
+
+ let vMin = Vector3.MagnitudeMax(v1, v2)
+
+ if vMin = v1 then
+ let v1LongerThanOrEqualTov2 = l1 >= l2
+ Assert.True(v1LongerThanOrEqualTov2)
+ else
+ let v2LongerThanv1 = l2 > l1
+ Assert.True(v2LongerThanv1)
+
+ []
+ let ``MagnitudeMin by reference selects the vector with equal or lesser magnitude given two vectors`` (v1 : Vector3, v2: Vector3) =
+ let l1 = v1.LengthSquared
+ let l2 = v2.LengthSquared
+
+ let vMin = Vector3.MagnitudeMin(ref v1, ref v2)
+
+ if vMin = v1 then
+ let v1ShorterThanv2 = l1 < l2
+ Assert.True(v1ShorterThanv2)
+ else
+ let v2ShorterThanOrEqualTov1 = l2 <= l1
+ Assert.True(v2ShorterThanOrEqualTov1)
+
+ []
+ let ``MagnitudeMax by reference selects the vector with equal or greater magnitude given two vectors`` (v1 : Vector3, v2: Vector3) =
+ let l1 = v1.LengthSquared
+ let l2 = v2.LengthSquared
+
+ let vMin = Vector3.MagnitudeMax(ref v1, ref v2)
+
+ if vMin = v1 then
+ let v1LongerThanOrEqualTov2 = l1 >= l2
+ Assert.True(v1LongerThanOrEqualTov2)
+ else
+ let v2LongerThanv1 = l2 > l1
+ Assert.True(v2LongerThanv1)
+
[ |])>]
module ``Component min and max`` =
//
[]
- let ``ComponentMin produces a new vector from the smallest components of the given vectors`` (x, y, z, u, w, q) =
- let v1 = Vector3(x, y, z)
- let v2 = Vector3(u, w, q)
-
+ let ``ComponentMin creates a new vector from the smallest components of given vectors`` (v1 : Vector3, v2: Vector3) =
let vMin = Vector3.ComponentMin(v1, v2)
+ let isComponentSmallest smallComp comp1 comp2 = smallComp <= comp1 && smallComp <= comp2
- Assert.True(vMin.X <= v1.X)
- Assert.True(vMin.X <= v2.X)
-
- Assert.True(vMin.Y <= v1.Y)
- Assert.True(vMin.Y <= v2.Y)
-
- Assert.True(vMin.Z <= v1.Z)
- Assert.True(vMin.Z <= v2.Z)
+ Assert.True(isComponentSmallest vMin.X v1.X v2.X)
+ Assert.True(isComponentSmallest vMin.Y v1.Y v2.Y)
+ Assert.True(isComponentSmallest vMin.Z v1.Z v2.Z)
[]
- let ``ComponentMax producing a new vector from the largest components of the given vectors`` (x, y, z, u, w, q) =
- let v1 = Vector3(x, y, z)
- let v2 = Vector3(u, w, q)
-
+ let ``ComponentMax creates a new vector from the greatest components of given vectors`` (v1 : Vector3, v2: Vector3) =
let vMax = Vector3.ComponentMax(v1, v2)
+ let isComponentLargest largeComp comp1 comp2 = largeComp >= comp1 && largeComp >= comp2
- Assert.True(vMax.X >= v1.X)
- Assert.True(vMax.X >= v2.X)
-
- Assert.True(vMax.Y >= v1.Y)
- Assert.True(vMax.Y >= v2.Y)
-
- Assert.True(vMax.Z >= v1.Z)
- Assert.True(vMax.Z >= v2.Z)
+ Assert.True(isComponentLargest vMax.X v1.X v2.X)
+ Assert.True(isComponentLargest vMax.Y v1.Y v2.Y)
+ Assert.True(isComponentLargest vMax.Z v1.Z v2.Z)
[]
- let ``ComponentMin by reference produces a new vector from the smallest components of the given vectors`` (x, y, z, u, w, q) =
- let v1 = Vector3(x, y, z)
- let v2 = Vector3(u, w, q)
-
+ let ``ComponentMin by reference creates a new vector from the smallest components of given vectors`` (v1 : Vector3, v2: Vector3) =
let vMin = Vector3.ComponentMin(ref v1, ref v2)
+ let isComponentSmallest smallComp comp1 comp2 = smallComp <= comp1 && smallComp <= comp2
- Assert.True(vMin.X <= v1.X)
- Assert.True(vMin.X <= v2.X)
-
- Assert.True(vMin.Y <= v1.Y)
- Assert.True(vMin.Y <= v2.Y)
-
- Assert.True(vMin.Z <= v1.Z)
- Assert.True(vMin.Z <= v2.Z)
+ Assert.True(isComponentSmallest vMin.X v1.X v2.X)
+ Assert.True(isComponentSmallest vMin.Y v1.Y v2.Y)
+ Assert.True(isComponentSmallest vMin.Z v1.Z v2.Z)
[]
- let ``ComponentMax produces a new vector from the smallest components of the given vectors`` (x, y, z, u, w, q) =
- let v1 = Vector3(x, y, z)
- let v2 = Vector3(u, w, q)
-
+ let ``ComponentMax by reference creates a new vector from the greatest components of given vectors`` (v1 : Vector3, v2: Vector3) =
let vMax = Vector3.ComponentMax(ref v1, ref v2)
+ let isComponentLargest largeComp comp1 comp2 = largeComp >= comp1 && largeComp >= comp2
- Assert.True(vMax.X >= v1.X)
- Assert.True(vMax.X >= v2.X)
-
- Assert.True(vMax.Y >= v1.Y)
- Assert.True(vMax.Y >= v2.Y)
-
- Assert.True(vMax.Z >= v1.Z)
- Assert.True(vMax.Z >= v2.Z)
-
- []
- let ``Min selects the vector with lesser magnitude given two vectors`` (x, y, z, u, w, q) =
- let v1 = Vector3(x, y, z)
- let v2 = Vector3(u, w, q)
-
- let l1 = v1.LengthSquared
- let l2 = v2.LengthSquared
-
- let vMin = Vector3.Min(v1, v2)
-
- if l1 < l2 then
- let equalsFirst = vMin = v1
- Assert.True(equalsFirst)
- else
- let equalsLast = vMin = v2
- Assert.True(equalsLast)
-
- []
- let ``Max selects the vector with greater magnitude given two vectors`` (x, y, z, u, w, q) =
- let v1 = Vector3(x, y, z)
- let v2 = Vector3(u, w, q)
-
- let l1 = v1.LengthSquared
- let l2 = v2.LengthSquared
-
- let vMin = Vector3.Max(v1, v2)
-
- if l1 >= l2 then
- let equalsFirst = vMin = v1
- Assert.True(equalsFirst)
- else
- let equalsLast = vMin = v2
- Assert.True(equalsLast)
+ Assert.True(isComponentLargest vMax.X v1.X v2.X)
+ Assert.True(isComponentLargest vMax.Y v1.Y v2.Y)
+ Assert.True(isComponentLargest vMax.Z v1.Z v2.Z)
[ |])>]
module Clamping =
diff --git a/tests/OpenTK.Tests/Vector4Tests.fs b/tests/OpenTK.Tests/Vector4Tests.fs
index 4a6fada3..193c77c5 100644
--- a/tests/OpenTK.Tests/Vector4Tests.fs
+++ b/tests/OpenTK.Tests/Vector4Tests.fs
@@ -692,34 +692,56 @@ module Vector4 =
Assert.Equal(dot, vRes)
[ |])>]
- module ``Component min and max`` =
+ module ``Magnitude min and max`` =
//
[]
- let ``Min selects the vector with lesser magnitude given two vectors`` (x, y, z, w, a, b, c, d) =
- let v1 = Vector4(x, y, z, w)
- let v2 = Vector4(a, b, c, d)
-
+ let ``MagnitudeMin selects the vector with equal or lesser magnitude given two vectors`` (v1 : Vector4, v2: Vector4) =
let l1 = v1.LengthSquared
let l2 = v2.LengthSquared
- let vMin = Vector4.Min(v1, v2)
+ let vMin = Vector4.MagnitudeMin(v1, v2)
if vMin = v1 then
let v1ShorterThanv2 = l1 < l2
Assert.True(v1ShorterThanv2)
else
- let v2ShorterThanv1 = l2 < l1
- Assert.True(v2ShorterThanv1)
+ let v2ShorterThanOrEqualTov1 = l2 <= l1
+ Assert.True(v2ShorterThanOrEqualTov1)
[]
- let ``Max selects the vector with greater magnitude given two vectors`` (x, y, z, w, a, b, c, d) =
- let v1 = Vector4(x, y, z, w)
- let v2 = Vector4(a, b, c, d)
-
+ let ``MagnitudeMax selects the vector with equal or greater magnitude given two vectors`` (v1 : Vector4, v2: Vector4) =
let l1 = v1.LengthSquared
let l2 = v2.LengthSquared
- let vMin = Vector4.Max(v1, v2)
+ let vMin = Vector4.MagnitudeMax(v1, v2)
+
+ if vMin = v1 then
+ let v1LongerThanOrEqualTov2 = l1 >= l2
+ Assert.True(v1LongerThanOrEqualTov2)
+ else
+ let v2LongerThanv1 = l2 > l1
+ Assert.True(v2LongerThanv1)
+
+ []
+ let ``MagnitudeMin by reference selects the vector with equal or lesser magnitude given two vectors`` (v1 : Vector4, v2: Vector4) =
+ let l1 = v1.LengthSquared
+ let l2 = v2.LengthSquared
+
+ let vMin = Vector4.MagnitudeMin(ref v1, ref v2)
+
+ if vMin = v1 then
+ let v1ShorterThanv2 = l1 < l2
+ Assert.True(v1ShorterThanv2)
+ else
+ let v2ShorterThanOrEqualTov1 = l2 <= l1
+ Assert.True(v2ShorterThanOrEqualTov1)
+
+ []
+ let ``MagnitudeMax by reference selects the vector with equal or greater magnitude given two vectors`` (v1 : Vector4, v2: Vector4) =
+ let l1 = v1.LengthSquared
+ let l2 = v2.LengthSquared
+
+ let vMin = Vector4.MagnitudeMax(ref v1, ref v2)
if vMin = v1 then
let v1LongerThanOrEqualTov2 = l1 >= l2
@@ -728,32 +750,76 @@ module Vector4 =
let v2LongerThanv1 = l2 > l1
Assert.True(v2LongerThanv1)
+ [ |])>]
+ module ``Component min and max`` =
+ //
+ []
+ let ``ComponentMin creates a new vector from the smallest components of given vectors`` (v1 : Vector4, v2: Vector4) =
+ let vMin = Vector4.ComponentMin(v1, v2)
+ let isComponentSmallest smallComp comp1 comp2 = smallComp <= comp1 && smallComp <= comp2
+
+ Assert.True(isComponentSmallest vMin.X v1.X v2.X)
+ Assert.True(isComponentSmallest vMin.Y v1.Y v2.Y)
+ Assert.True(isComponentSmallest vMin.Z v1.Z v2.Z)
+ Assert.True(isComponentSmallest vMin.W v1.W v2.W)
+
+ []
+ let ``ComponentMax creates a new vector from the greatest components of given vectors`` (v1 : Vector4, v2: Vector4) =
+ let vMax = Vector4.ComponentMax(v1, v2)
+ let isComponentLargest largeComp comp1 comp2 = largeComp >= comp1 && largeComp >= comp2
+
+ Assert.True(isComponentLargest vMax.X v1.X v2.X)
+ Assert.True(isComponentLargest vMax.Y v1.Y v2.Y)
+ Assert.True(isComponentLargest vMax.Z v1.Z v2.Z)
+ Assert.True(isComponentLargest vMax.W v1.W v2.W)
+
+ []
+ let ``ComponentMin by reference creates a new vector from the smallest components of given vectors`` (v1 : Vector4, v2: Vector4) =
+ let vMin = Vector4.ComponentMin(ref v1, ref v2)
+ let isComponentSmallest smallComp comp1 comp2 = smallComp <= comp1 && smallComp <= comp2
+
+ Assert.True(isComponentSmallest vMin.X v1.X v2.X)
+ Assert.True(isComponentSmallest vMin.Y v1.Y v2.Y)
+ Assert.True(isComponentSmallest vMin.Z v1.Z v2.Z)
+ Assert.True(isComponentSmallest vMin.W v1.W v2.W)
+
+ []
+ let ``ComponentMax by reference creates a new vector from the greatest components of given vectors`` (v1 : Vector4, v2: Vector4) =
+ let vMax = Vector4.ComponentMax(ref v1, ref v2)
+ let isComponentLargest largeComp comp1 comp2 = largeComp >= comp1 && largeComp >= comp2
+
+ Assert.True(isComponentLargest vMax.X v1.X v2.X)
+ Assert.True(isComponentLargest vMax.Y v1.Y v2.Y)
+ Assert.True(isComponentLargest vMax.Z v1.Z v2.Z)
+ Assert.True(isComponentLargest vMax.W v1.W v2.W)
+
+
[ |])>]
module Clamping =
//
[]
let ``Clamping one vector between two other vectors clamps all components between corresponding components`` (a : Vector4, b : Vector4, w : Vector4) =
- let res = Vector4.Clamp(w, a, b)
-
let expX = if w.X < a.X then a.X else if w.X > b.X then b.X else w.X
let expY = if w.Y < a.Y then a.Y else if w.Y > b.Y then b.Y else w.Y
let expZ = if w.Z < a.Z then a.Z else if w.Z > b.Z then b.Z else w.Z
let expW = if w.W < a.W then a.W else if w.W > b.W then b.W else w.W
+ let res = Vector4.Clamp(w, a, b)
+
Assert.Equal(expX, res.X)
Assert.Equal(expY, res.Y)
Assert.Equal(expZ, res.Z)
Assert.Equal(expW, res.W)
[]
- let ``Clamping one vector between two other vectors by reference clamps all components`` (a : Vector4, b : Vector4, w : Vector4) =
- let res = Vector4.Clamp(ref w, ref a, ref b)
-
+ let ``Clamping one vector between two other vectors by reference clamps all components between corresponding components`` (a : Vector4, b : Vector4, w : Vector4) =
let expX = if w.X < a.X then a.X else if w.X > b.X then b.X else w.X
let expY = if w.Y < a.Y then a.Y else if w.Y > b.Y then b.Y else w.Y
let expZ = if w.Z < a.Z then a.Z else if w.Z > b.Z then b.Z else w.Z
let expW = if w.W < a.W then a.W else if w.W > b.W then b.W else w.W
+ let res = Vector4.Clamp(ref w, ref a, ref b)
+
Assert.Equal(expX, res.X)
Assert.Equal(expY, res.Y)
Assert.Equal(expZ, res.Z)