Class Mathf
- Namespace
- BasilEngine.Mathematics
- Assembly
- BasilEngine.dll
[Disabled]
public static class Mathf
- Inheritance
-
Mathf
- Inherited Members
Properties
Deg2Rad
Conversion multiplier from degrees to radians.
public static float Deg2Rad { get; }
Property Value
Epsilon
Smallest positive non-zero value greater than zero.
public static float Epsilon { get; }
Property Value
Infinity
Represents positive infinity.
public static float Infinity { get; }
Property Value
NegativeInfinity
Represents negative infinity.
public static float NegativeInfinity { get; }
Property Value
PI
The constant value of pi.
public static float PI { get; }
Property Value
Rad2Deg
Conversion multiplier from radians to degrees.
public static float Rad2Deg { get; }
Property Value
Methods
Abs(float)
Gets the absolute value of a float.
public static float Abs(float f)
Parameters
ffloatInput value.
Returns
- float
Absolute value of the input.
Acos(float)
Calculates the arccosine of a value.
public static float Acos(float f)
Parameters
ffloatInput value.
Returns
- float
Angle in radians whose cosine is the input.
Approximately(float, float)
Determines whether two floats are approximately equal.
public static bool Approximately(float a, float b)
Parameters
Returns
- bool
True if the values are within a small epsilon.
Asin(float)
Calculates the arcsine of a value.
public static float Asin(float f)
Parameters
ffloatInput value.
Returns
- float
Angle in radians whose sine is the input.
Atan(float)
Calculates the arctangent of a value.
public static float Atan(float f)
Parameters
ffloatInput value.
Returns
- float
Angle in radians whose tangent is the input.
Atan2(float, float)
Calculates the angle whose tangent is the quotient of two numbers.
public static float Atan2(float y, float x)
Parameters
Returns
- float
Angle in radians between the positive X-axis and the point.
Ceil(float)
Returns the smallest integral value greater than or equal to the specified number.
public static float Ceil(float f)
Parameters
ffloatInput value.
Returns
- float
Ceiling of the input.
CeilToInt(float)
Returns the smallest integral value greater than or equal to the specified number as an int.
public static int CeilToInt(float f)
Parameters
ffloatInput value.
Returns
- int
Ceiling of the input as an int.
Clamp(int, int, int)
Clamps an int between a minimum and maximum value.
public static int Clamp(int value, int min, int max)
Parameters
Returns
- int
Clamped value.
Clamp(float, float, float)
Clamps a float between a minimum and maximum value.
public static float Clamp(float value, float min, float max)
Parameters
Returns
- float
Clamped value.
Clamp01(float)
Clamps a value between 0 and 1.
public static float Clamp01(float result)
Parameters
resultfloatInput value.
Returns
- float
Value clamped to the [0,1] range.
ClosestPowerOfTwo(int)
Finds the closest power of two that is greater than or equal to the specified value.
public static int ClosestPowerOfTwo(int value)
Parameters
valueintInput value.
Returns
- int
Next power of two.
CorrelatedColorTemperatureToRGB(float)
Converts a correlated color temperature in Kelvin to an RGB color.
public static Color CorrelatedColorTemperatureToRGB(float kelvin)
Parameters
kelvinfloatTemperature in Kelvin.
Returns
- Color
RGB color approximating the temperature.
Cos(float)
Calculates the cosine of an angle in radians.
public static float Cos(float radians)
Parameters
radiansfloatAngle in radians.
Returns
- float
Cosine of the input angle.
DeltaAngle(float, float)
Calculates the shortest delta between two angles in degrees.
public static float DeltaAngle(float current, float target)
Parameters
Returns
- float
Signed minimal angle difference.
Exp(float)
Returns e raised to the specified power.
public static float Exp(float power)
Parameters
powerfloatExponent to raise e to.
Returns
- float
Result of e^power.
FloatToHalf(float)
Converts a float into an unsigned 16-bit value representing the high 16 bits.
public static ushort FloatToHalf(float f)
Parameters
ffloatFloat to convert.
Returns
- ushort
High 16 bits of the float.
Floor(float)
Returns the largest integer less than or equal to the specified value.
public static float Floor(float f)
Parameters
ffloatInput value.
Returns
- float
Floor of the input.
FloorToInt(float)
Returns the largest integer less than or equal to the specified value as an int.
public static int FloorToInt(float f)
Parameters
ffloatInput value.
Returns
- int
Floor of the input as an int.
GammaToLinearSpace(float)
Converts a value from gamma (sRGB) to linear space.
public static float GammaToLinearSpace(float f)
Parameters
ffloatGamma-space value.
Returns
- float
Linear-space value.
HalfToFloat(ushort)
Converts the high 16 bits of an integer into a float.
public static float HalfToFloat(ushort val)
Parameters
valushortHalf value.
Returns
- float
Converted float.
InverseLerp(float, float, float)
Calculates the linear parameter that produces the interpolant value within the range [a, b].
public static float InverseLerp(float a, float b, float value)
Parameters
Returns
- float
Normalized position between 0 and 1.
IsPowerOfTwo(int)
Determines if a value is a power of two.
public static bool IsPowerOfTwo(int value)
Parameters
valueintInput value.
Returns
- bool
True if the value is a power of two.
Lerp(float, float, float)
Linearly interpolates between two values with clamping.
public static float Lerp(float a, float b, float t)
Parameters
Returns
- float
Interpolated value.
LerpAngle(float, float, float)
Interpolates between two angles taking the shortest path.
public static float LerpAngle(float a, float b, float t)
Parameters
afloatStart angle in degrees.
bfloatEnd angle in degrees.
tfloatInterpolation factor in [0,1].
Returns
- float
Interpolated angle in degrees.
LerpUnclamped(float, float, float)
Linearly interpolates between two values without clamping the interpolation factor.
public static float LerpUnclamped(float a, float b, float t)
Parameters
Returns
- float
Interpolated value.
LinearToGammaSpace(float)
Converts a value from linear space to gamma (sRGB) space.
public static float LinearToGammaSpace(float f)
Parameters
ffloatLinear-space value.
Returns
- float
Gamma-space value.
Log(float)
Natural logarithm of a specified value.
public static float Log(float f)
Parameters
ffloatInput value.
Returns
- float
Natural log of the input.
Log10(float)
Base-10 logarithm of a specified value.
public static float Log10(float f)
Parameters
ffloatInput value.
Returns
- float
Log base 10 of the input.
Max(float, float)
Returns the larger of two floating-point numbers.
public static float Max(float a, float b)
Parameters
Returns
Min(float, float)
Returns the smaller of two floating-point numbers.
public static float Min(float a, float b)
Parameters
Returns
MoveTowards(float, float, float)
Moves a value towards a target by a maximum change.
public static float MoveTowards(float current, float target, float maxDelta)
Parameters
Returns
- float
New value after applying the move.
MoveTowardsAngle(float, float, float)
Moves an angle towards a target angle by a maximum change, accounting for wraparound.
public static float MoveTowardsAngle(float current, float target, float maxDelta)
Parameters
Returns
NextPowerOfTwo(int)
Returns the smallest power of two that is greater than or equal to the specified value.
public static float NextPowerOfTwo(int value)
Parameters
valueint
Returns
PingPong(float, float)
Ping-pongs a value between 0 and length.
public static float PingPong(float t, float length)
Parameters
Returns
Pow(float, float)
Raises a number to a specified power.
public static float Pow(float f, float p)
Parameters
Returns
Repeat(float, float)
Repeats a value in the range [0, length).
public static float Repeat(float t, float length)
Parameters
Returns
Round(float)
Rounds a value to the nearest integer.
public static float Round(float f)
Parameters
ffloat
Returns
RoundToInt(float)
Rounds a value to the nearest integer and returns it as an int.
public static int RoundToInt(float f)
Parameters
ffloat
Returns
Sign(float)
Gets the sign of a value.
public static float Sign(float f)
Parameters
ffloat
Returns
Sin(float)
Calculates the sine of an angle in radians.
public static float Sin(float radians)
Parameters
radiansfloatAngle in radians.
Returns
- float
Sine of the input angle.
SmoothDamp(float, float, ref float, float, float, float)
Smoothly damps a value towards a target using a critically damped spring function.
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime)
Parameters
Returns
SmoothDampAngle(float, float, ref float, float, float, float)
Smoothly damps an angle towards a target angle using a critically damped spring function.
public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime)
Parameters
Returns
SmoothStep(float, float, float)
Interpolates between two values using a smooth cubic curve.
public static float SmoothStep(float from, float to, float t)
Parameters
Returns
Sqrt(float)
Returns the square root of a value.
public static float Sqrt(float f)
Parameters
ffloat
Returns
Tan(float)
Returns the tangent of the specified angle in radians.
public static float Tan(float f)
Parameters
ffloat