Class Mathf
- Namespace
- Lime
- Assembly
- Lime.dll
public static class Mathf
- Inheritance
-
Mathf
- Inherited Members
Fields
DegToRad
public const float DegToRad = 0.017453292
Field Value
E
public const float E = 2.7182817
Field Value
HalfPi
public const float HalfPi = 1.5707964
Field Value
Pi
public const float Pi = 3.1415927
Field Value
RadToDeg
public const float RadToDeg = 57.295776
Field Value
RandomGenerator
public static Random RandomGenerator
Field Value
TwoPi
public const float TwoPi = 6.2831855
Field Value
ZeroTolerance
public const float ZeroTolerance = 1E-06
Field Value
Methods
Abs(Vector2)
Returns Vector2 with absolute values of corresponding components of v
public static Vector2 Abs(Vector2 v)
Parameters
v
Vector2
Returns
Abs(Vector3)
Returns Vector3 with absolute values of corresponding components of v
public static Vector3 Abs(Vector3 v)
Parameters
v
Vector3
Returns
Abs(float)
Returns absolute value of v
. Equals to -v
if v
less than 0 or v
otherwise.
public static float Abs(float v)
Parameters
v
float
Returns
Acos(float)
public static float Acos(float v)
Parameters
v
float
Returns
Asin(float)
public static float Asin(float v)
Parameters
v
float
Returns
Atan2(Vector2)
public static float Atan2(Vector2 v)
Parameters
v
Vector2
Returns
Atan2(float, float)
public static float Atan2(float y, float x)
Parameters
Returns
CalcDistanceToSegment(Vector2, Vector2, Vector2)
public static float CalcDistanceToSegment(Vector2 start, Vector2 end, Vector2 point)
Parameters
Returns
CalcLowerPowerOfTwo(int)
public static int CalcLowerPowerOfTwo(int x)
Parameters
x
int
Returns
CalcUpperPowerOfTwo(int)
public static int CalcUpperPowerOfTwo(int x)
Parameters
x
int
Returns
CatmullRomSpline(float, Vector2, Vector2, Vector2, Vector2)
public static Vector2 CatmullRomSpline(float t, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3)
Parameters
Returns
CatmullRomSpline(float, Vector3, Vector3, Vector3, Vector3)
public static Vector3 CatmullRomSpline(float t, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3)
Parameters
Returns
CatmullRomSpline(float, float, float, float, float)
public static float CatmullRomSpline(float t, float p0, float p1, float p2, float p3)
Parameters
Returns
Clamp(Vector2, Vector2, Vector2)
public static Vector2 Clamp(Vector2 value, Vector2 min, Vector2 max)
Parameters
Returns
Clamp(double, double, double)
public static double Clamp(double value, double min, double max)
Parameters
Returns
Clamp(int, int, int)
public static int Clamp(int value, int min, int max)
Parameters
Returns
Clamp(float, float, float)
public static float Clamp(float value, float min, float max)
Parameters
Returns
Cos(float)
public static float Cos(float radians)
Parameters
radians
float
Returns
CubicBezier(float, Vector2, Vector2, Vector2, Vector2)
public static Vector2 CubicBezier(float t, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3)
Parameters
Returns
CubicBezier(float, Vector3, Vector3, Vector3, Vector3)
public static Vector3 CubicBezier(float t, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3)
Parameters
Returns
CubicBezier(float, float, float, float, float)
public static float CubicBezier(float t, float p0, float p1, float p2, float p3)
Parameters
Returns
CubicBezierDerivative(float, Vector2, Vector2, Vector2, Vector2)
public static Vector2 CubicBezierDerivative(float t, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3)
Parameters
Returns
CubicBezierDerivative(float, Vector3, Vector3, Vector3, Vector3)
public static Vector3 CubicBezierDerivative(float t, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3)
Parameters
Returns
CubicBezierDerivative(float, float, float, float, float)
public static float CubicBezierDerivative(float t, float p0, float p1, float p2, float p3)
Parameters
Returns
CubicBezierSecondDerivative(float, float, float, float, float)
public static float CubicBezierSecondDerivative(float t, float p0, float p1, float p2, float p3)
Parameters
Returns
Erf(double)
Gauss error function. The maximum error is below 1.5 × 10-7.
public static double Erf(double x)
Parameters
x
double
Returns
Erf(float)
public static float Erf(float x)
Parameters
x
float
Returns
Exp(float)
public static float Exp(float x)
Parameters
x
float
Returns
FastInverseSqrt(float)
public static float FastInverseSqrt(float x)
Parameters
x
float
Returns
HermiteSpline(float, Vector2, Vector2, Vector2, Vector2)
public static Vector2 HermiteSpline(float t, Vector2 p0, Vector2 m0, Vector2 p1, Vector2 m1)
Parameters
Returns
HermiteSpline(float, Vector3, Vector3, Vector3, Vector3)
public static Vector3 HermiteSpline(float t, Vector3 p0, Vector3 m0, Vector3 p1, Vector3 m1)
Parameters
Returns
HermiteSpline(float, float, float, float, float)
public static float HermiteSpline(float t, float p0, float m0, float p1, float m1)
Parameters
Returns
HermiteSplineDerivative(float, Vector2, Vector2, Vector2, Vector2)
public static Vector2 HermiteSplineDerivative(float t, Vector2 p0, Vector2 m0, Vector2 p1, Vector2 m1)
Parameters
Returns
HermiteSplineDerivative(float, float, float, float, float)
public static float HermiteSplineDerivative(float t, float p0, float m0, float p1, float m1)
Parameters
Returns
InRange(float, float, float)
public static bool InRange(float x, float upper, float lower)
Parameters
Returns
Lerp(float, Vector2, Vector2)
public static Vector2 Lerp(float amount, Vector2 value1, Vector2 value2)
Parameters
Returns
Lerp(float, Vector3, Vector3)
public static Vector3 Lerp(float amount, Vector3 value1, Vector3 value2)
Parameters
Returns
Lerp(float, float, float)
public static float Lerp(float amount, float value1, float value2)
Parameters
Returns
Log(float)
public static float Log(float x)
Parameters
x
float
Returns
Max(float, float)
public static float Max(float x, float y)
Parameters
Returns
Min(float, float)
public static float Min(float x, float y)
Parameters
Returns
NormalRandom(IRandom, float, float)
public static float NormalRandom(this IRandom rng, float median, float dispersion)
Parameters
Returns
NormalRandom(Random, float, float)
public static float NormalRandom(this Random rng, float median, float dispersion)
Parameters
Returns
NormalRandom(float, float)
public static float NormalRandom(float median, float dispersion)
Parameters
Returns
Pow(float, float)
public static float Pow(float x, float y)
Parameters
Returns
RandomBool()
public static bool RandomBool()
Returns
RandomBool(Random)
public static bool RandomBool(this Random rng)
Parameters
rng
Random
Returns
RandomDouble(IRandom, double, double)
public static double RandomDouble(this IRandom rng, double min, double max)
Parameters
Returns
RandomDouble(double, double)
public static double RandomDouble(double min, double max)
Parameters
Returns
RandomDouble(Random, double, double)
public static double RandomDouble(this Random rng, double min, double max)
Parameters
Returns
RandomFloat()
Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
public static float RandomFloat()
Returns
- float
A single-precision floating point number that is greater than or equal to 0.0, and less than 1.0.
Remarks
The actual upper bound of the random number returned by this method is 0.99999999999999978.
RandomFloat(IRandom)
public static float RandomFloat(this IRandom rng)
Parameters
rng
IRandom
Returns
RandomFloat(IRandom, float, float)
public static float RandomFloat(this IRandom rng, float min, float max)
Parameters
Returns
RandomFloat(Random)
Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0 and produced by specified generator.
public static float RandomFloat(this Random rng)
Parameters
rng
RandomThe instance of a random generator.
Returns
- float
A single-precision floating point number that is greater than or equal to 0.0, and less than 1.0.
Remarks
The actual upper bound of the random number returned by this method is 0.99999999999999978.
RandomFloat(Random, float, float)
Returns a random floating-point number that is within a specified range and produced by specified generator.
public static float RandomFloat(this Random rng, float min, float max)
Parameters
rng
RandomThe instance of a random generator.
min
floatThe inclusive lower bound of the random number returned.
max
floatThe exclusive upper bound of the random number returned.
Returns
- float
A single-precision floating point number that is greater than or equal to min, and less than max.
RandomFloat(float, float)
Returns a random floating-point number that is within a specified range.
public static float RandomFloat(float min, float max)
Parameters
min
floatThe inclusive lower bound of the random number returned.
max
floatThe exclusive upper bound of the random number returned.
Returns
- float
A single-precision floating point number that is greater than or equal to min, and less than max.
RandomInt(IRandom, int)
public static int RandomInt(this IRandom rng, int maxValue)
Parameters
Returns
RandomInt(int)
Returns a non-negative random integer that is less than the specified maximum.
public static int RandomInt(int maxValue)
Parameters
maxValue
intThe exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to 0.
Returns
- int
A 32-bit signed integer that is greater than or equal to 0, and less than maxValue; that is, the range of return values ordinarily includes 0 but not maxValue. However, if maxValue equals 0, maxValue is returned.
RandomInt(int, int)
Returns a random integer that is within a specified range.
public static int RandomInt(int min, int max)
Parameters
min
intThe inclusive lower bound of the random number returned.
max
intThe inclusive upper bound of the random number returned. max must be greater than or equal to (min - 1).
Returns
- int
A 32-bit signed integer greater than or equal to min and not greater than max; that is, the range of return values includes both min and max. If max equals min or (min - 1), min is returned.
RandomInt(Random, int)
Returns a non-negative random integer that is less than the specified maximum and produced by specified generator.
public static int RandomInt(this Random rng, int maxValue)
Parameters
rng
RandomThe instance of a random generator.
maxValue
intThe exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to 0.
Returns
- int
A 32-bit signed integer that is greater than or equal to 0, and less than maxValue; that is, the range of return values ordinarily includes 0 but not maxValue. However, if maxValue equals 0, maxValue is returned.
RandomInt(Random, int, int)
Returns a random integer that is within a specified range and produced by specified generator.
public static int RandomInt(this Random rng, int min, int max)
Parameters
rng
RandomThe instance of a random generator.
min
intThe inclusive lower bound of the random number returned.
max
intThe inclusive upper bound of the random number returned. max must be greater than or equal to (min - 1).
Returns
- int
A 32-bit signed integer greater than or equal to min and not greater than max; that is, the range of return values includes both min and max. If max equals min or (min - 1), min is returned.
RandomItem<T>(ICollection<T>)
public static T RandomItem<T>(this ICollection<T> objects)
Parameters
objects
ICollection<T>
Returns
- T
Type Parameters
T
RandomOf<T>(IRandom, ICollection<T>)
public static T RandomOf<T>(this IRandom rng, ICollection<T> objects)
Parameters
rng
IRandomobjects
ICollection<T>
Returns
- T
Type Parameters
T
RandomOf<T>(IRandom, params T[])
public static T RandomOf<T>(this IRandom rng, params T[] objects)
Parameters
rng
IRandomobjects
T[]
Returns
- T
Type Parameters
T
RandomOf<T>(Random, ICollection<T>)
public static T RandomOf<T>(this Random rng, ICollection<T> objects)
Parameters
rng
Randomobjects
ICollection<T>
Returns
- T
Type Parameters
T
RandomOf<T>(Random, params T[])
public static T RandomOf<T>(this Random rng, params T[] objects)
Parameters
rng
Randomobjects
T[]
Returns
- T
Type Parameters
T
RandomOf<T>(params T[])
public static T RandomOf<T>(params T[] objects)
Parameters
objects
T[]
Returns
- T
Type Parameters
T
Shuffle<T>(IEnumerable<T>, IRandom)
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source, IRandom rng)
Parameters
source
IEnumerable<T>rng
IRandom
Returns
- IEnumerable<T>
Type Parameters
T
Shuffle<T>(IEnumerable<T>, Random)
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source, Random rng = null)
Parameters
source
IEnumerable<T>rng
Random
Returns
- IEnumerable<T>
Type Parameters
T
Sign(Vector2)
public static Vector2 Sign(Vector2 x)
Parameters
x
Vector2
Returns
Sign(float)
public static int Sign(float x)
Parameters
x
float
Returns
Sin(float)
public static float Sin(float radians)
Parameters
radians
float
Returns
SolveCubicBezier(float, float, float, float, float, float)
Finds cubic Bezier curve parameter t in [0; 1] at which curve evaulates to v. v is also expected to be in [0; 1]
public static float SolveCubicBezier(float v, float p0, float p1, float p2, float p3, float epsilon)
Parameters
Returns
Sqr(float)
public static float Sqr(float x)
Parameters
x
float
Returns
Sqrt(float)
public static float Sqrt(float x)
Parameters
x
float
Returns
UniformRandom(IRandom, float, float)
public static float UniformRandom(this IRandom rng, float median, float dispersion)
Parameters
Returns
UniformRandom(Random, float, float)
public static float UniformRandom(this Random rng, float median, float dispersion)
Parameters
Returns
UniformRandom(float, float)
public static float UniformRandom(float median, float dispersion)
Parameters
Returns
Wrap(int, int, int)
public static int Wrap(int x, int lowerBound, int upperBound)
Parameters
Returns
Wrap(float, float, float)
public static float Wrap(float x, float lowerBound, float upperBound)
Parameters
Returns
Wrap180(float)
public static float Wrap180(float angle)
Parameters
angle
float
Returns
Wrap360(float)
public static float Wrap360(float angle)
Parameters
angle
float