Class MathUtils
Inheritance
Inherited Members
Namespace: AGS.API
Assembly: AGS.API.dll
Syntax
public static class MathUtils
Methods
| Improve this Doc View SourceClamp(Single, Single, Single)
Clamps "x" to be between min and max.
Declaration
public static float Clamp(float x, float min, float max)
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | The x coordinate. |
System.Single | min | Minimum. |
System.Single | max | Maximum. |
Returns
Type | Description |
---|---|
System.Single | The clamp. |
DegreesToRadians(Single)
Converts degrees to radians.
Declaration
public static float DegreesToRadians(float degrees)
Parameters
Type | Name | Description |
---|---|---|
System.Single | degrees | Degrees. |
Returns
Type | Description |
---|---|
System.Single | The radians. |
Distance(PointF, PointF)
Returns the distance between 2 points.
Declaration
public static float Distance(PointF p1, PointF p2)
Parameters
Type | Name | Description |
---|---|---|
PointF | p1 | First point |
PointF | p2 | Second point |
Returns
Type | Description |
---|---|
System.Single | The distance between the points |
FloatEquals(Single, Single)
Compare two floating numbers (with tolerance, as this is the only sensible way to compare floats: http://floating-point-gui.de/).
Declaration
public static bool FloatEquals(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
System.Single | x | The x coordinate. |
System.Single | y | The y coordinate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
GetNextPowerOf2(Int32)
Gets the next number after "v" which is a power of 2.
Declaration
public static int GetNextPowerOf2(int v)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | v | The value. |
Returns
Type | Description |
---|---|
System.Int32 | The next power of 2. |
IsPowerOf2(Int32)
Is "x" the power of 2?
Declaration
public static bool IsPowerOf2(int x)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The x coordinate. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Lerp(Single, Single, Single, Single, Single)
Performs a linear interpolation between values (https://en.wikipedia.org/wiki/Linear_interpolation).
Declaration
public static float Lerp(float x1, float y1, float x2, float y2, float targetX)
Parameters
Type | Name | Description |
---|---|---|
System.Single | x1 | The first x value. |
System.Single | y1 | The first y value. |
System.Single | x2 | The second x value. |
System.Single | y2 | The second y value. |
System.Single | targetX | Target x. |
Returns
Type | Description |
---|---|
System.Single | The interpolated value. |
Max(Single[])
Returns the maximum between multiple values.
Declaration
public static float Max(params float[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Single[] | values | Values. |
Returns
Type | Description |
---|---|
System.Single | The max. |
Min(Single[])
Returns a minimum between multiple values.
Declaration
public static float Min(params float[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Single[] | values | Values. |
Returns
Type | Description |
---|---|
System.Single | The minimum. |
Random()
Returns a thread local random number generator.
Declaration
public static Random Random()
Returns
Type | Description |
---|---|
System.Random | The random number generator. |