Quantum 3
3.1.0
A collection of common math functions. More...
Static Public Member Functions | |
| static FP | Abs (FP value) |
| Returns the absolute value of the argument. More... | |
| static Int32 | Abs (Int32 value) |
| Returns the absolute value of the argument. More... | |
| static Int64 | Abs (Int64 value) |
| Returns the absolute value of the argument. More... | |
| static FP | AngleBetweenDegrees (FP source, FP target) |
| Calculates the smallest signed angle between any two angles. F.e. angle between -179 and 179 is -2. Rotation is ccw. More... | |
| static Int64 | AngleBetweenDegreesRaw (Int64 source, Int64 target) |
| Same as AngleBetweenDegrees using Raw optimization. More... | |
| static FP | AngleBetweenRadians (FP source, FP target) |
| Calculates the smallest signed angle between any two angles. More... | |
| static Int64 | AngleBetweenRadiansRaw (Int64 source, Int64 target) |
| Same as AngleBetweenDegrees using Raw optimization. More... | |
| static FP | Barycentric (FP value1, FP value2, FP value3, FP t1, FP t2) |
| Performs barycentric interpolation. More... | |
| static FP | CatmullRom (FP value1, FP value2, FP value3, FP value4, FP t) |
| Performs Cotmull-Rom interpolation. More... | |
| static FP | Ceiling (FP value) |
| Returns the smallest integer larger than or equal to value . More... | |
| static Int32 | CeilToInt (FP value) |
| Returns the smallest integer larger than or equal to value . More... | |
| static FP | Clamp (FP value, FP min, FP max) |
| Clamps the given value between the given minimum and maximum values. More... | |
| static Int32 | Clamp (Int32 value, Int32 min, Int32 max) |
| Clamps the given value between the given minimum and maximum values. More... | |
| static Int64 | Clamp (Int64 value, Int64 min, Int64 max) |
| Clamps the given value between the given minimum and maximum values. More... | |
| static FP | Clamp01 (FP value) |
| Clamps the given value between 0 and 1. More... | |
| static FP | ClampUseable (FP value) |
| Clamps the given value between FP.UseableMin and FP.UseableMax. More... | |
| static FP | Floor (FP value) |
| Returns the largest integer smaller than or equal to value . More... | |
| static Int64 | FloorRaw (Int64 value) |
| static Int32 | FloorToInt (FP value) |
| Returns the largest integer smaller than or equal to value . More... | |
| static FP | Fraction (FP value) |
| Returns the fractional part of the argument. More... | |
| static FP | Hermite (FP value1, FP tangent1, FP value2, FP tangent2, FP t) |
| Performs cubic Hermite interpolation. More... | |
| static FP | InverseLerp (FP start, FP end, FP value) |
| Calculates the linear parameter that produces the interpolant value within the range [start , end ]. The result is clamped to the range [0, 1]. More... | |
| static FP | InverseLerpUnclamped (FP start, FP end, FP value) |
| Calculates the linear parameter that produces the interpolant value within the range [start , end ]. More... | |
| static FP | Lerp (FP start, FP end, FP t) |
| Linearly interpolates between start and end by t . t is clamped to the range [0, 1] More... | |
| static FP | LerpRadians (FP start, FP end, FP t) |
| Linearly interpolates between start and end by t . t is clamped to the range [0, 1]. The difference between start and end is converted to a [-Pi/2, Pi/2] range. More... | |
| static FP | LerpUnclamped (FP start, FP end, FP t) |
| Linearly interpolates between start and end by t . More... | |
| static Int32 | Log2CeilingToInt (FP value) |
| Returns celining of the logarithm of value in base 2. It is much faster than calling FPMath.Log2(FP) and then FPMath.CeilToInt(FP) More... | |
| static Int32 | Log2FloorToInt (FP value) |
| Returns floor of the logarithm of value in base 2. It is much faster than calling FPMath.Log2(FP) and then FPMath.FloorToInt(FP) More... | |
| static FP | Max (FP a, FP b, FP c) |
| Returns the maximum of three values. More... | |
| static FP | Max (FP val1, FP val2) |
| Returns the largest of two or more values. More... | |
| static Int32 | Max (Int32 a, Int32 b) |
| Returns the larger of two values. More... | |
| static Int64 | Max (Int64 a, Int64 b) |
| Returns the larger of two values. More... | |
| static FP | Max (params FP[] numbers) |
| Returns the largest of two or more values. More... | |
| static FP | Min (FP a, FP b, FP c) |
| Returns the minimum of three values. More... | |
| static FP | Min (FP val1, FP val2) |
| Returns the smallest of two or more values. More... | |
| static Int32 | Min (Int32 a, Int32 b) |
| Returns the smaller of two values. More... | |
| static Int64 | Min (Int64 a, Int64 b) |
| Returns the smaller of two values. More... | |
| static FP | Min (params FP[] numbers) |
| Returns the smallest of two or more values. More... | |
| static void | MinMax (FP a, FP b, out FP min, out FP max) |
| static FP | ModuloClamped (FP a, FP n) |
| Performs modulo operation without forcing the sign of the dividend: So that ModuloClamped(-9, 10) = 1. More... | |
| static Int64 | ModuloClamped (Int64 a, Int64 n) |
| Performs modulo operation without forcing the sign of the dividend: So that ModuloClamped(-9, 10) = 1. More... | |
| static FP | MoveTowards (FP from, FP to, FP maxDelta) |
| Moves a value from towards to by a value no greater than maxDelta . Negative values of maxDelta push the value away from to . More... | |
| static Int32 | NextPowerOfTwo (Int32 value) |
| Returns the next power of two that is equal to, or greater than, the argument. More... | |
| static FP | Repeat (FP t, FP length) |
| Loops the value t , so that it is never larger than length and never smaller than 0. More... | |
| static FP | Round (FP value) |
| Returns value rounded to the nearest integer. More... | |
| static Int32 | RoundToInt (FP value) |
| Returns value rounded to the nearest integer. More... | |
| static FP | Sign (FP value) |
| Returns the sign of value . More... | |
| static Int32 | SignInt (FP value) |
| Returns the sign of value . More... | |
| static FP | SignZero (FP value) |
| Returns the sign of value if it is non-zero. More... | |
| static Int32 | SignZeroInt (FP value) |
| Returns the sign of value if it is non-zero. More... | |
| static FP | SmoothStep (FP start, FP end, FP t) |
| Interpolates between start and end with smoothing at the limits. Equivalent of calling Hermite(FP, FP, FP, FP, FP) with tangents set to 0 and clamping t between 0 and 1. More... | |
| static unsafe void | Sort< T > (Span< T > span, int lo, int hi, delegate *< T *, T *, int > comparer) |
| Sorts elements in a buffer using an introsort algorithm with guaranteed O(n log n) worst-case time complexity. The sort is unstable and deterministic. More... | |
| static unsafe void | Sort< T > (T *buffer, int lo, int hi, delegate *< T *, T *, int > comparer) |
| Sorts elements in a buffer using an introsort algorithm with guaranteed O(n log n) worst-case time complexity. The sort is unstable and deterministic. More... | |
| static unsafe void | Sort< T, TField > (Span< T > span, int lo, int hi, int fieldOffset) |
| Sorts elements in a buffer using an introsort algorithm with guaranteed O(n log n) worst-case time complexity. The sort is unstable and deterministic. More... | |
| static unsafe void | Sort< T, TField > (T *buffer, int lo, int hi, int fieldOffset) |
| Sorts elements in a buffer using an introsort algorithm with guaranteed O(n log n) worst-case time complexity. The sort is unstable and deterministic. More... | |
A collection of common math functions.
Returns the sign of value .
| value |
Returns the sign of value if it is non-zero.
| value |
|
inlinestatic |
Returns the sign of value .
| value |
|
inlinestatic |
Returns the sign of value if it is non-zero.
| value |
|
inlinestatic |
Returns the next power of two that is equal to, or greater than, the argument.
| value |
Returns the absolute value of the argument.
| value |
Returns value rounded to the nearest integer.
| value |
|
inlinestatic |
Returns value rounded to the nearest integer.
| value |
Returns the largest integer smaller than or equal to value .
| value |
|
inlinestatic |
Returns the largest integer smaller than or equal to value .
| value |
Returns the smallest integer larger than or equal to value .
| value |
|
inlinestatic |
Returns the smallest integer larger than or equal to value .
| value |
Returns the largest of two or more values.
| val1 | |
| val2 |
Returns the smallest of two or more values.
| val1 | |
| val2 |
Returns the smallest of two or more values.
| numbers |
Returns the minimum of three values.
| a | |
| b | |
| c |
Returns the maximum of three values.
| a | |
| b | |
| c |
Returns the largest of two or more values.
| numbers |
| a | |
| b | |
| min | |
| max |
Clamps the given value between the given minimum and maximum values.
| value | |
| min | |
| max |
Clamps the given value between 0 and 1.
| value |
|
inlinestatic |
Clamps the given value between the given minimum and maximum values.
| value | |
| min | |
| max |
|
inlinestatic |
Clamps the given value between the given minimum and maximum values.
| value | |
| min | |
| max |
|
inlinestatic |
Returns the absolute value of the argument.
|
inlinestatic |
Returns the absolute value of the argument.
|
inlinestatic |
Returns the smaller of two values.
|
inlinestatic |
Returns the smaller of two values.
|
inlinestatic |
Returns the larger of two values.
|
inlinestatic |
Returns the larger of two values.
Returns the fractional part of the argument.
| value |
Loops the value t , so that it is never larger than length and never smaller than 0.
| t | |
| length |
Linearly interpolates between start and end by t . t is clamped to the range [0, 1]. The difference between start and end is converted to a [-Pi/2, Pi/2] range.
| start | |
| end | |
| t |
Linearly interpolates between start and end by t . t is clamped to the range [0, 1]
| start | |
| end | |
| t |
Linearly interpolates between start and end by t .
| start | |
| end | |
| t |
Calculates the linear parameter that produces the interpolant value within the range [start , end ]. The result is clamped to the range [0, 1].
Returns 0 if start and end are equal.
| start | |
| end | |
| value |
|
inlinestatic |
Calculates the linear parameter that produces the interpolant value within the range [start , end ].
The resultant factor is NOT clamped to the range [0, 1].
Returns 0 if start and end are equal.
| start | |
| end | |
| value |
Moves a value from towards to by a value no greater than maxDelta . Negative values of maxDelta push the value away from to .
| from | |
| to | |
| maxDelta |
Interpolates between start and end with smoothing at the limits. Equivalent of calling Hermite(FP, FP, FP, FP, FP) with tangents set to 0 and clamping t between 0 and 1.
| start | |
| end | |
| t |
|
inlinestatic |
Performs barycentric interpolation.
| value1 | |
| value2 | |
| value3 | |
| t1 | |
| t2 |
|
inlinestatic |
Performs Cotmull-Rom interpolation.
| value1 | |
| value2 | |
| value3 | |
| value4 | |
| t |
|
inlinestatic |
Performs cubic Hermite interpolation.
| value1 | |
| tangent1 | |
| value2 | |
| tangent2 | |
| t |
|
inlinestatic |
Performs modulo operation without forcing the sign of the dividend: So that ModuloClamped(-9, 10) = 1.
| a | Dividend |
| n | Divisor |
| System.InvalidOperationException | When n > Int64.MaxValue >> 2 or n < Int64.MinValue >> 2 |
| System.DivideByZeroException | When n == 0 |
Performs modulo operation without forcing the sign of the dividend: So that ModuloClamped(-9, 10) = 1.
| a | Dividend |
| n | Divisor |
| System.InvalidOperationException | When n > FP.UseableMax or n < FP.UseableMin |
| System.DivideByZeroException | When n == 0 |
Calculates the smallest signed angle between any two angles. F.e. angle between -179 and 179 is -2. Rotation is ccw.
| source | Source angle in degrees |
| target | Target angle in degrees |
|
inlinestatic |
Same as AngleBetweenDegrees using Raw optimization.
| source | Source angle in degrees (Raw) |
| target | Target angle in degrees (Raw) |
Calculates the smallest signed angle between any two angles.
| source | Source angle in radians |
| target | Target angle in radians |
|
inlinestatic |
Same as AngleBetweenDegrees using Raw optimization.
| source | Source angle in radians (Raw) |
| target | Target angle in radians (Raw) |
|
inlinestatic |
Returns floor of the logarithm of value in base 2. It is much faster than calling FPMath.Log2(FP) and then FPMath.FloorToInt(FP)
| value |
|
inlinestatic |
Returns celining of the logarithm of value in base 2. It is much faster than calling FPMath.Log2(FP) and then FPMath.CeilToInt(FP)
| value |
|
inlinestatic |
Sorts elements in a buffer using an introsort algorithm with guaranteed O(n log n) worst-case time complexity. The sort is unstable and deterministic.
| span | Span to sort. |
| lo | Inclusive lower bound index. |
| hi | Inclusive upper bound index. |
| comparer | Function pointer returning negative if *a < *b, positive if *a > *b, zero if equal. |
| T | : | unmanaged |
|
inlinestatic |
Sorts elements in a buffer using an introsort algorithm with guaranteed O(n log n) worst-case time complexity. The sort is unstable and deterministic.
| buffer | Pointer to the first element of the buffer to sort. |
| lo | Inclusive lower bound index. |
| hi | Inclusive upper bound index. |
| comparer | Function pointer returning negative if *a < *b, positive if *a > *b, zero if equal. |
| T | : | unmanaged |
|
inlinestatic |
Sorts elements in a buffer using an introsort algorithm with guaranteed O(n log n) worst-case time complexity. The sort is unstable and deterministic.
| span | Span to sort. |
| lo | Inclusive lower bound index. |
| hi | Inclusive upper bound index. |
| fieldOffset | Offset of the comparable field that will be used for sorting. |
| T | Type of the elements in buffer to sort. |
| TField | Type of the field in each element that will be used for comparison when sorting. |
| T | : | unmanaged | |
| TField | : | unmanaged | |
| TField | : | IComparable<TField> |
|
inlinestatic |
Sorts elements in a buffer using an introsort algorithm with guaranteed O(n log n) worst-case time complexity. The sort is unstable and deterministic.
| buffer | Pointer to the first element of the buffer to sort. |
| lo | Inclusive lower bound index. |
| hi | Inclusive upper bound index. |
| fieldOffset | Offset of the comparable field that will be used for sorting. |
| T | Type of the elements in buffer to sort. |
| TField | Type of the field in each element that will be used for comparison when sorting. |
| T | : | unmanaged | |
| TField | : | unmanaged | |
| TField | : | IComparable<TField> |