using Microsoft.Xna.Framework;
namespace MonoGame.Extended;
public static class MathExtended
{
///
/// Represents the smallest positive value that can be added to 1.0 to produce a distinguishable result.
/// This value is approximately 1.19209290e-7 and is useful for floating-point comparisons.
///
public const float MachineEpsilon = 1.19209290e-7f;
///
/// Calculates a new with the component-wise minimum values from two given
/// values.
///
/// The first Vector2 value.
/// The second Vector2 value.
///
/// The calculated value with the component-wise minimum values.
public static Vector2 CalculateMinimumVector2(Vector2 first, Vector2 second)
{
return new Vector2
{
X = first.X < second.X ? first.X : second.X,
Y = first.Y < second.Y ? first.Y : second.Y
};
}
///
/// Calculates a new with the component-wise minimum values from two given
/// values.
///
/// The first Vector2 value.
/// The second Vector2 value.
///
/// When this method returns, contains the calculated value with the component-wise minimum
/// values. This parameter is passed uninitialized.
///
public static void CalculateMinimumVector2(Vector2 first, Vector2 second, out Vector2 result)
{
result.X = first.X < second.X ? first.X : second.X;
result.Y = first.Y < second.Y ? first.Y : second.Y;
}
///
/// Calculates a new with the component-wise minimum values from two given
/// values.
///
/// The first Vector2 value.
/// The second Vector2 value.
/// The calculated value with the component-wise maximum values.
public static Vector2 CalculateMaximumVector2(Vector2 first, Vector2 second)
{
return new Vector2
{
X = first.X > second.X ? first.X : second.X,
Y = first.Y > second.Y ? first.Y : second.Y
};
}
///
/// Calculates a new with the component-wise values from two given
/// values.
///
/// The first Vector2 value.
/// The second Vector2 value.
///
/// When this method returns, contains the calculated value with the component-wise maximum
/// values. This parameter is passed uninitialized.
///
public static void CalculateMaximumVector2(Vector2 first, Vector2 second, out Vector2 result)
{
result.X = first.X > second.X ? first.X : second.X;
result.Y = first.Y > second.Y ? first.Y : second.Y;
}
}