Class GLMathf
- Namespace
- Gamelogic.Extensions
- Assembly
- Assembly-CSharp.dll
Methods for additional math functions.
[Version(1, 4, 0)]
public static class GLMathf
- Inheritance
-
GLMathf
- Inherited Members
Fields
Sqrt3
public static readonly float Sqrt3
Field Value
Methods
Div(int, int)
[Obsolete("Use FloorDiv instead")]
public static int Div(int m, int n)
Parameters
Returns
FloorDiv(int, int)
Floor division that also work for negative m.
[Version(2, 2, 0)]
public static int FloorDiv(int m, int n)
Parameters
Returns
- int
System.Int32.
FloorMod(int, int)
Mod operator that also works for negative m.
[Version(2, 2, 0)]
public static int FloorMod(int m, int n)
Parameters
Returns
- int
System.Int32.
FloorMod(float, float)
Mod operator that also works for negative m.
[Version(2, 2, 0)]
public static float FloorMod(float m, float n)
Parameters
Returns
- float
System.Int32.
FloorToInt(float)
Returns the highest integer equal to the given float.
[Obsolete("Use Mathf.FloorToInt")]
public static int FloorToInt(float x)
Parameters
x
float
Returns
Frac(float)
Returns the fractional part of a floating point number.
public static float Frac(float x)
Parameters
x
floatThe number to get the fractional part of.
Returns
- float
The fractional part of the given number.
Remarks
The result is always the number minus the number's floor.
InRange(float, float, float)
Tests whether the given value lies in the half-open interval specified by its endpoints, that is, whether the value
lies in the interval [closedLeft, openRight)
.
public static bool InRange(float value, float closedLeft, float openRight)
Parameters
value
floatThe value to check.
closedLeft
floatThe left end of the interval.
openRight
floatThe right end of the interval.
Returns
- bool
true
if the given value is equal or greater thanclosedLeft
and smaller thanopenRight
,false
otherwise.
InRange01(float)
Tests whether the given value lies in the range [0, 1).
public static bool InRange01(float value)
Parameters
value
floatThe value to check.
Returns
- bool
true
if the given value is equal or greater than 0 and smaller than 1,false
otherwise.
Mod(int, int)
[Obsolete("Use FloorMod instead")]
public static int Mod(int m, int n)
Parameters
Returns
Mod(float, float)
[Obsolete("Use FloorMod instead")]
public static float Mod(float m, float n)
Parameters
Returns
Sign(int)
Returns the sign function evaluated at the given value.
public static int Sign(int p)
Parameters
p
int
Returns
- int
1 if the given value is positive, -1 if it is negative, and 0 if it is 0.
Sign(float)
Returns the sign function evaluated at the given value.
public static int Sign(float x)
Parameters
x
float
Returns
- int
1 if the given value is positive, -1 if it is negative, and 0 if it is 0.
Wlerp01(float, float, float)
Linearly interpolates between two values between 0 and 1 if values wrap around from 1 back to 0.
public static float Wlerp01(float v1, float v2, float t)
Parameters
Returns
Examples
float angleInRad1 = 1;
float angleInRad2 = 5;
float revolution = Mathf.PI * 2;
float interpolation = WLerp(angleInRad1 / revolution, angleInRad2 / revolution, 0.5f);
//interpolation == (5 + 1 + Mathf.PI * 2)/2 = 3 + Mathf.PI
Remarks
This is useful, for example, in lerping between angles.
Wrap01(float)
[Obsolete("Use Frac instead.")]
public static float Wrap01(float value)
Parameters
value
float