Class MathUtilities
Provides math utilities not provided in System.Math.
[Unstable("This API might be removed in next major version. Please use corresponding BCL APIs.")]
public static class MathUtilities
- Inheritance
-
MathUtilities
- Inherited Members
Methods
AreClose(double, double)
AreClose - Returns whether or not two doubles are "close". That is, whether or not they are within epsilon of each other.
public static bool AreClose(double value1, double value2)
Parameters
Returns
AreClose(double, double, double)
AreClose - Returns whether or not two doubles are "close". That is, whether or not they are within epsilon of each other.
public static bool AreClose(double value1, double value2, double eps)
Parameters
value1
doubleThe first double to compare.
value2
doubleThe second double to compare.
eps
doubleThe fixed epsilon value used to compare.
Returns
AreClose(float, float)
AreClose - Returns whether or not two floats are "close". That is, whether or not they are within epsilon of each other.
public static bool AreClose(float value1, float value2)
Parameters
Returns
Clamp(decimal, decimal, decimal)
Clamps a value between a minimum and maximum value.
public static decimal Clamp(decimal val, decimal min, decimal max)
Parameters
Returns
- decimal
The clamped value.
Clamp(double, double, double)
Clamps a value between a minimum and maximum value.
public static double Clamp(double val, double min, double max)
Parameters
Returns
- double
The clamped value.
Clamp(int, int, int)
Clamps a value between a minimum and maximum value.
public static int Clamp(int val, int min, int max)
Parameters
Returns
- int
The clamped value.
Clamp(float, float, float)
Clamps a value between a minimum and maximum value.
public static float Clamp(float value, float min, float max)
Parameters
Returns
- float
The clamped value.
Deg2Rad(double)
Converts an angle in degrees to radians.
public static double Deg2Rad(double angle)
Parameters
angle
doubleThe angle in degrees.
Returns
- double
The angle in radians.
GetEllipsePoint(Point, double, double, double)
Calculates the point of an angle on an ellipse.
public static Point GetEllipsePoint(Point centre, double radiusX, double radiusY, double angle)
Parameters
centre
PointThe centre point of the ellipse.
radiusX
doubleThe x radius of the ellipse.
radiusY
doubleThe y radius of the ellipse.
angle
doubleThe angle in radians.
Returns
- Point
A point on the ellipse.
GetMinMax(double, double)
Gets the minimum and maximum from the specified numbers.
public static (double min, double max) GetMinMax(double a, double b)
Parameters
Returns
GetMinMaxFromDelta(double, double)
Gets the minimum and maximum from the specified number and the difference with that number.
public static (double min, double max) GetMinMaxFromDelta(double initialValue, double delta)
Parameters
Returns
- (double min, double max)
A tuple containing the minimum and maximum of the specified number and the difference with that number.
Grad2Rad(double)
Converts an angle in gradians to radians.
public static double Grad2Rad(double angle)
Parameters
angle
doubleThe angle in gradians.
Returns
- double
The angle in radians.
GreaterThan(double, double)
GreaterThan - Returns whether or not the first double is greater than the second double. That is, whether or not the first is strictly greater than and not within epsilon of the other number.
public static bool GreaterThan(double value1, double value2)
Parameters
Returns
GreaterThan(float, float)
GreaterThan - Returns whether or not the first float is greater than the second float. That is, whether or not the first is strictly greater than and not within epsilon of the other number.
public static bool GreaterThan(float value1, float value2)
Parameters
Returns
GreaterThanOrClose(double, double)
GreaterThanOrClose - Returns whether or not the first double is greater than or close to the second double. That is, whether or not the first is strictly greater than or within epsilon of the other number.
public static bool GreaterThanOrClose(double value1, double value2)
Parameters
Returns
GreaterThanOrClose(float, float)
GreaterThanOrClose - Returns whether or not the first float is greater than or close to the second float. That is, whether or not the first is strictly greater than or within epsilon of the other number.
public static bool GreaterThanOrClose(float value1, float value2)
Parameters
Returns
IsOne(double)
IsOne - Returns whether or not the double is "close" to 1. Same as AreClose(double, 1), but this is faster.
public static bool IsOne(double value)
Parameters
value
doubleThe double to compare to 1.
Returns
IsOne(float)
IsOne - Returns whether or not the float is "close" to 1. Same as AreClose(float, 1), but this is faster.
public static bool IsOne(float value)
Parameters
value
floatThe float to compare to 1.
Returns
IsZero(double)
IsZero - Returns whether or not the double is "close" to 0. Same as AreClose(double, 0), but this is faster.
public static bool IsZero(double value)
Parameters
value
doubleThe double to compare to 0.
Returns
IsZero(float)
IsZero - Returns whether or not the float is "close" to 0. Same as AreClose(float, 0), but this is faster.
public static bool IsZero(float value)
Parameters
value
floatThe float to compare to 0.
Returns
LessThan(double, double)
LessThan - Returns whether or not the first double is less than the second double. That is, whether or not the first is strictly less than and not within epsilon of the other number.
public static bool LessThan(double value1, double value2)
Parameters
Returns
LessThan(float, float)
LessThan - Returns whether or not the first float is less than the second float. That is, whether or not the first is strictly less than and not within epsilon of the other number.
public static bool LessThan(float value1, float value2)
Parameters
Returns
LessThanOrClose(double, double)
LessThanOrClose - Returns whether or not the first double is less than or close to the second double. That is, whether or not the first is strictly less than or within epsilon of the other number.
public static bool LessThanOrClose(double value1, double value2)
Parameters
Returns
LessThanOrClose(float, float)
LessThanOrClose - Returns whether or not the first float is less than or close to the second float. That is, whether or not the first is strictly less than or within epsilon of the other number.
public static bool LessThanOrClose(float value1, float value2)
Parameters
Returns
Turn2Rad(double)
Converts an angle in turns to radians.
public static double Turn2Rad(double angle)
Parameters
angle
doubleThe angle in turns.
Returns
- double
The angle in radians.