Nebula
|
Contains commonly used precalculated values and mathematical operations.
Static Public Member Functions | |
static float | Barycentric (float value1, float value2, float value3, float amount1, float amount2) |
Returns the Cartesian coordinate for one axis of a point that is defined by a given triangle and two normalized barycentric (areal) coordinates. | |
static float | CatmullRom (float value1, float value2, float value3, float value4, float amount) |
Performs a Catmull-Rom interpolation using the specified positions. | |
static float | Clamp (float value, float min, float max) |
Restricts a value to be within a specified range. | |
static int | Clamp (int value, int min, int max) |
Restricts a value to be within a specified range. | |
static float | Distance (float value1, float value2) |
Calculates the absolute value of the difference of two values. | |
static float | Hermite (float value1, float tangent1, float value2, float tangent2, float amount) |
Performs a Hermite spline interpolation. | |
static float | Lerp (float value1, float value2, float amount) |
Linearly interpolates between two values. | |
static float | LerpPrecise (float value1, float value2, float amount) |
Linearly interpolates between two values. | |
static float | Max (float value1, float value2) |
Returns the greater of two values. | |
static int | Max (int value1, int value2) |
Returns the greater of two values. | |
static float | Min (float value1, float value2) |
Returns the lesser of two values. | |
static int | Min (int value1, int value2) |
Returns the lesser of two values. | |
static float | SmoothStep (float value1, float value2, float amount) |
Interpolates between two values using a cubic equation. | |
static float | ToDegrees (float radians) |
Converts radians to degrees. | |
static float | ToRadians (float degrees) |
Converts degrees to radians. | |
static float | WrapAngle (float angle) |
Reduces a given angle to a value between π and -π. | |
static bool | IsPowerOfTwo (int value) |
Determines if value is powered by two. | |
Static Public Attributes | |
const float | E = (float)System.Math.E |
Represents the mathematical constant e(2.71828175). | |
const float | Log10E = 0.4342945f |
Represents the log base ten of e(0.4342945). | |
const float | Log2E = 1.442695f |
Represents the log base two of e(1.442695). | |
const float | Pi = (float)System.Math.PI |
Represents the value of pi(3.14159274). | |
const float | PiOver2 = (float)(System.Math.PI / 2.0) |
Represents the value of pi divided by two(1.57079637). | |
const float | PiOver4 = (float)(System.Math.PI / 4.0) |
Represents the value of pi divided by four(0.7853982). | |
const float | TwoPi = (float)(System.Math.PI * 2.0) |
Represents the value of pi times two(6.28318548). | |
|
inlinestatic |
Returns the Cartesian coordinate for one axis of a point that is defined by a given triangle and two normalized barycentric (areal) coordinates.
value1 | The coordinate on one axis of vertex 1 of the defining triangle. |
value2 | The coordinate on the same axis of vertex 2 of the defining triangle. |
value3 | The coordinate on the same axis of vertex 3 of the defining triangle. |
amount1 | The normalized barycentric (areal) coordinate b2, equal to the weighting factor for vertex 2, the coordinate of which is specified in value2. |
amount2 | The normalized barycentric (areal) coordinate b3, equal to the weighting factor for vertex 3, the coordinate of which is specified in value3. |
|
inlinestatic |
Performs a Catmull-Rom interpolation using the specified positions.
value1 | The first position in the interpolation. |
value2 | The second position in the interpolation. |
value3 | The third position in the interpolation. |
value4 | The fourth position in the interpolation. |
amount | Weighting factor. |
|
inlinestatic |
Restricts a value to be within a specified range.
value | The value to clamp. |
min | The minimum value. If value is less than min , min will be returned. |
max | The maximum value. If value is greater than max , max will be returned. |
|
inlinestatic |
Restricts a value to be within a specified range.
value | The value to clamp. |
min | The minimum value. If value is less than min , min will be returned. |
max | The maximum value. If value is greater than max , max will be returned. |
|
inlinestatic |
Calculates the absolute value of the difference of two values.
value1 | Source value. |
value2 | Source value. |
|
inlinestatic |
Performs a Hermite spline interpolation.
value1 | Source position. |
tangent1 | Source tangent. |
value2 | Source position. |
tangent2 | Source tangent. |
amount | Weighting factor. |
|
inlinestatic |
Determines if value is powered by two.
value | A value. |
true
if value
is powered by two; otherwise false
.
|
inlinestatic |
Linearly interpolates between two values.
value1 | Source value. |
value2 | Destination value. |
amount | Value between 0 and 1 indicating the weight of value2. |
This method performs the linear interpolation based on the following formula:
. Passing amount a value of 0 will cause value1 to be returned, a value of 1 will cause value2 to be returned. See MathHelper.LerpPrecise for a less efficient version with more precision around edge cases.
|
inlinestatic |
Linearly interpolates between two values.
This method is a less efficient, more precise version of MathHelper.Lerp. See remarks for more info.
value1 | Source value. |
value2 | Destination value. |
amount | Value between 0 and 1 indicating the weight of value2. |
This method performs the linear interpolation based on the following formula:
. Passing amount a value of 0 will cause value1 to be returned, a value of 1 will cause value2 to be returned. This method does not have the floating point precision issue that MathHelper.Lerp has. i.e. If there is a big gap between value1 and value2 in magnitude (e.g. value1=10000000000000000, value2=1), right at the edge of the interpolation range (amount=1), MathHelper.Lerp will return 0 (whereas it should return 1). This also holds for value1=10^17, value2=10; value1=10^18,value2=10^2... so on. For an in depth explanation of the issue, see below references: Relevant Wikipedia Article: https://en.wikipedia.org/wiki/Linear_interpolation#Programming_language_support Relevant StackOverflow Answer: http://stackoverflow.com/questions/4353525/floating-point-linear-interpolation#answer-23716956
|
inlinestatic |
Returns the greater of two values.
value1 | Source value. |
value2 | Source value. |
|
inlinestatic |
Returns the greater of two values.
value1 | Source value. |
value2 | Source value. |
|
inlinestatic |
Returns the lesser of two values.
value1 | Source value. |
value2 | Source value. |
|
inlinestatic |
Returns the lesser of two values.
value1 | Source value. |
value2 | Source value. |
|
inlinestatic |
Interpolates between two values using a cubic equation.
value1 | Source value. |
value2 | Source value. |
amount | Weighting value. |
|
inlinestatic |
Converts radians to degrees.
radians | The angle in radians. |
This method uses double precission internally, though it returns single float Factor = 180 / pi
|
inlinestatic |
Converts degrees to radians.
degrees | The angle in degrees. |
This method uses double precission internally, though it returns single float Factor = pi / 180
|
inlinestatic |
Reduces a given angle to a value between π and -π.
angle | The angle to reduce, in radians. |
|
static |
Represents the mathematical constant e(2.71828175).
|
static |
Represents the log base ten of e(0.4342945).
|
static |
Represents the log base two of e(1.442695).
|
static |
Represents the value of pi(3.14159274).
|
static |
Represents the value of pi divided by two(1.57079637).
|
static |
Represents the value of pi divided by four(0.7853982).
|
static |
Represents the value of pi times two(6.28318548).