mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-24 03:36:56 +00:00
Renamed Min/Max to ComponentMin/ComponentMax and added Min and Max functions based on vector length.
This commit is contained in:
parent
2520233f26
commit
e2b08d0bd6
|
@ -398,67 +398,97 @@ namespace OpenTK.Math
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Min
|
#region ComponentMin
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculate the component-wise minimum of two vectors
|
/// Calculate the component-wise minimum of two vectors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="a">First operand</param>
|
/// <param name="a">First operand</param>
|
||||||
/// <param name="b">Second operand</param>
|
/// <param name="b">Second operand</param>
|
||||||
/// <returns>The component-wise minimum</returns>
|
/// <returns>The component-wise minimum</returns>
|
||||||
public static Vector3 Min(Vector3 a, Vector3 b)
|
public static Vector3 ComponentMin(Vector3 a, Vector3 b)
|
||||||
{
|
{
|
||||||
a.X = a.X < b.X ? a.X : b.X;
|
a.X = a.X < b.X ? a.X : b.X;
|
||||||
a.Y = a.Y < b.Y ? a.Y : b.Y;
|
a.Y = a.Y < b.Y ? a.Y : b.Y;
|
||||||
a.Z = a.Z < b.Z ? a.Z : b.Z;
|
a.Z = a.Z < b.Z ? a.Z : b.Z;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculate the component-wise minimum of two vectors
|
/// Calculate the component-wise minimum of two vectors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="a">First operand</param>
|
/// <param name="a">First operand</param>
|
||||||
/// <param name="b">Second operand</param>
|
/// <param name="b">Second operand</param>
|
||||||
/// <param name="result">The component-wise minimum</param>
|
/// <param name="result">The component-wise minimum</param>
|
||||||
public static void Min(ref Vector3 a, ref Vector3 b, out Vector3 result)
|
public static void ComponentMin(ref Vector3 a, ref Vector3 b, out Vector3 result)
|
||||||
{
|
{
|
||||||
result.X = a.X < b.X ? a.X : b.X;
|
result.X = a.X < b.X ? a.X : b.X;
|
||||||
result.Y = a.Y < b.Y ? a.Y : b.Y;
|
result.Y = a.Y < b.Y ? a.Y : b.Y;
|
||||||
result.Z = a.Z < b.Z ? a.Z : b.Z;
|
result.Z = a.Z < b.Z ? a.Z : b.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Max
|
#region ComponentMax
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculate the component-wise maximum of two vectors
|
/// Calculate the component-wise maximum of two vectors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="a">First operand</param>
|
/// <param name="a">First operand</param>
|
||||||
/// <param name="b">Second operand</param>
|
/// <param name="b">Second operand</param>
|
||||||
/// <returns>The component-wise maximum</returns>
|
/// <returns>The component-wise maximum</returns>
|
||||||
public static Vector3 Max(Vector3 a, Vector3 b)
|
public static Vector3 ComponentMax(Vector3 a, Vector3 b)
|
||||||
{
|
{
|
||||||
a.X = a.X > b.X ? a.X : b.X;
|
a.X = a.X > b.X ? a.X : b.X;
|
||||||
a.Y = a.Y > b.Y ? a.Y : b.Y;
|
a.Y = a.Y > b.Y ? a.Y : b.Y;
|
||||||
a.Z = a.Z > b.Z ? a.Z : b.Z;
|
a.Z = a.Z > b.Z ? a.Z : b.Z;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculate the component-wise maximum of two vectors
|
/// Calculate the component-wise maximum of two vectors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="a">First operand</param>
|
/// <param name="a">First operand</param>
|
||||||
/// <param name="b">Second operand</param>
|
/// <param name="b">Second operand</param>
|
||||||
/// <param name="result">The component-wise maximum</param>
|
/// <param name="result">The component-wise maximum</param>
|
||||||
public static void Max(ref Vector3 a, ref Vector3 b, out Vector3 result)
|
public static void ComponentMax(ref Vector3 a, ref Vector3 b, out Vector3 result)
|
||||||
{
|
{
|
||||||
result.X = a.X > b.X ? a.X : b.X;
|
result.X = a.X > b.X ? a.X : b.X;
|
||||||
result.Y = a.Y > b.Y ? a.Y : b.Y;
|
result.Y = a.Y > b.Y ? a.Y : b.Y;
|
||||||
result.Z = a.Z > b.Z ? a.Z : b.Z;
|
result.Z = a.Z > b.Z ? a.Z : b.Z;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Min
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Vector3 with the minimum magnitude
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="left">Left operand</param>
|
||||||
|
/// <param name="right">Right operand</param>
|
||||||
|
/// <returns>The minimum Vector3</returns>
|
||||||
|
public static Vector3 Min(Vector3 left, Vector3 right)
|
||||||
|
{
|
||||||
|
return left.LengthSquared < right.LengthSquared ? left : right;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Max
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Vector3 with the minimum magnitude
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="left">Left operand</param>
|
||||||
|
/// <param name="right">Right operand</param>
|
||||||
|
/// <returns>The minimum Vector3</returns>
|
||||||
|
public static Vector3 Max(Vector3 left, Vector3 right)
|
||||||
|
{
|
||||||
|
return left.LengthSquared >= right.LengthSquared ? left : right;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Clamp
|
#region Clamp
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue