cesium-native
0.41.0
|
Mathematical constants and functions. More...
#include <CesiumUtility/Math.h>
Static Public Member Functions | |
template<glm::length_t L, typename T , glm::qualifier Q> | |
static constexpr glm::vec< L, T, Q > | relativeEpsilonToAbsolute (const glm::vec< L, T, Q > &a, const glm::vec< L, T, Q > &b, double relativeEpsilon) noexcept |
Converts a relative to an absolute epsilon, for the epsilon-equality check between two values. More... | |
static constexpr double | relativeEpsilonToAbsolute (double a, double b, double relativeEpsilon) noexcept |
Converts a relative to an absolute epsilon, for the epsilon-equality check between two values. More... | |
template<glm::length_t L, typename T , glm::qualifier Q> | |
static constexpr bool | equalsEpsilon (const glm::vec< L, T, Q > &left, const glm::vec< L, T, Q > &right, double relativeEpsilon) noexcept |
Checks whether two values are equal up to a given relative epsilon. More... | |
static constexpr bool | equalsEpsilon (double left, double right, double relativeEpsilon) noexcept |
Checks whether two values are equal up to a given relative epsilon. More... | |
static constexpr bool | equalsEpsilon (double left, double right, double relativeEpsilon, double absoluteEpsilon) noexcept |
Determines if two values are equal using an absolute or relative tolerance test. More... | |
template<glm::length_t L, typename T , glm::qualifier Q> | |
static constexpr bool | equalsEpsilon (const glm::vec< L, T, Q > &left, const glm::vec< L, T, Q > &right, double relativeEpsilon, double absoluteEpsilon) noexcept |
Determines if two values are equal using an absolute or relative tolerance test. More... | |
static constexpr double | sign (double value) noexcept |
Returns the sign of the value. More... | |
static constexpr double | signNotZero (double value) noexcept |
Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative. More... | |
static double | negativePiToPi (double angle) noexcept |
Produces an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle. More... | |
static double | zeroToTwoPi (double angle) noexcept |
Produces an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle. More... | |
static double | mod (double m, double n) noexcept |
The modulo operation that also works for negative dividends. More... | |
static constexpr double | degreesToRadians (double angleDegrees) noexcept |
Converts degrees to radians. More... | |
static constexpr double | radiansToDegrees (double angleRadians) noexcept |
Converts radians to degrees. More... | |
static double | lerp (double p, double q, double time) noexcept |
Computes the linear interpolation of two values. More... | |
static constexpr double | clamp (double value, double min, double max) noexcept |
Constrain a value to lie between two values. More... | |
static double | toSNorm (double value, double rangeMaximum=255.0) noexcept |
Converts a scalar value in the range [-1.0, 1.0] to a SNORM in the range [0, rangeMaximum]. More... | |
static constexpr double | fromSNorm (double value, double rangeMaximum=255.0) noexcept |
Converts a SNORM value in the range [0, rangeMaximum] to a scalar in the range [-1.0, 1.0]. More... | |
static double | convertLongitudeRange (double angle) noexcept |
static double | roundUp (double value, double tolerance) noexcept |
Rounds a value up to the nearest integer, like ceil , except that if the value is very close to the lower integer it is rounded down (like floor ) instead. More... | |
static double | roundDown (double value, double tolerance) noexcept |
Rounds a value down to the nearest integer, like floor , except that if the value is very close to the higher integer it is rounded up (like ceil ) instead. More... | |
template<typename T , glm::qualifier Q> | |
static glm::vec< 3, T, Q > | perpVec (const glm::vec< 3, T, Q > &v) |
Construct a vector perpendicular to the argument. More... | |
template<typename T , glm::qualifier Q> | |
static glm::qua< T, Q > | rotation (const glm::vec< 3, T, Q > &vec1, const glm::vec< 3, T, Q > &vec2) |
Compute the rotation between two unit vectors. More... | |
Static Public Attributes | |
static constexpr double | Epsilon1 = 1e-1 |
0.1 | |
static constexpr double | Epsilon2 = 1e-2 |
0.01 | |
static constexpr double | Epsilon3 = 1e-3 |
0.001 | |
static constexpr double | Epsilon4 = 1e-4 |
0.0001 | |
static constexpr double | Epsilon5 = 1e-5 |
0.00001 | |
static constexpr double | Epsilon6 = 1e-6 |
0.000001 | |
static constexpr double | Epsilon7 = 1e-7 |
0.0000001 | |
static constexpr double | Epsilon8 = 1e-8 |
0.00000001 | |
static constexpr double | Epsilon9 = 1e-9 |
0.000000001 | |
static constexpr double | Epsilon10 = 1e-10 |
0.0000000001 | |
static constexpr double | Epsilon11 = 1e-11 |
0.00000000001 | |
static constexpr double | Epsilon12 = 1e-12 |
0.000000000001 | |
static constexpr double | Epsilon13 = 1e-13 |
0.0000000000001 | |
static constexpr double | Epsilon14 = 1e-14 |
0.00000000000001 | |
static constexpr double | Epsilon15 = 1e-15 |
0.000000000000001 | |
static constexpr double | Epsilon16 = 1e-16 |
0.0000000000000001 | |
static constexpr double | Epsilon17 = 1e-17 |
0.00000000000000001 | |
static constexpr double | Epsilon18 = 1e-18 |
0.000000000000000001 | |
static constexpr double | Epsilon19 = 1e-19 |
0.0000000000000000001 | |
static constexpr double | Epsilon20 = 1e-20 |
0.00000000000000000001 | |
static constexpr double | Epsilon21 = 1e-21 |
0.000000000000000000001 | |
static constexpr double | OnePi = 3.14159265358979323846 |
pi | |
static constexpr double | TwoPi = OnePi * 2.0 |
two times pi | |
static constexpr double | PiOverTwo = OnePi / 2.0 |
pi divded by two | |
|
inlinestaticconstexprnoexcept |
|
inlinestaticnoexcept |
Converts a longitude value, in radians, to the range [-Math::OnePi
, Math::OnePi
).
angle | The longitude value, in radians, to convert to the range [-Math::OnePi , Math::OnePi ). |
-Math::OnePi
, Math::OnePi
).
|
inlinestaticconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
Checks whether two values are equal up to a given relative epsilon.
L | The length type. |
T | value value type. |
Q | The GLM qualifier type. |
left | The first value. |
right | The second value. |
relativeEpsilon | The relative epsilon. |
|
inlinestaticconstexprnoexcept |
Determines if two values are equal using an absolute or relative tolerance test.
This is useful to avoid problems due to roundoff error when comparing floating-point values directly. The values are first compared using an absolute tolerance test. If that fails, a relative tolerance test is performed. Use this test if you are unsure of the magnitudes of left and right.
L | The length type. |
T | value value type. |
Q | The GLM qualifier type. |
left | The first value to compare. |
right | The other value to compare. |
relativeEpsilon | The maximum inclusive delta between left and right for the relative tolerance test. |
absoluteEpsilon | The maximum inclusive delta between left and right for the absolute tolerance test. |
true
if the values are equal within the epsilon; otherwise, false
.
|
inlinestaticconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
Determines if two values are equal using an absolute or relative tolerance test.
This is useful to avoid problems due to roundoff error when comparing floating-point values directly. The values are first compared using an absolute tolerance test. If that fails, a relative tolerance test is performed. Use this test if you are unsure of the magnitudes of left and right.
left | The first value to compare. |
right | The other value to compare. |
relativeEpsilon | The maximum inclusive delta between left and right for the relative tolerance test. |
absoluteEpsilon | The maximum inclusive delta between left and right for the absolute tolerance test. |
true
if the values are equal within the epsilon; otherwise, false
.
|
inlinestaticconstexprnoexcept |
Converts a SNORM value in the range [0, rangeMaximum] to a scalar in the range [-1.0, 1.0].
value | SNORM value in the range [0, rangeMaximum]. |
rangeMaximum | The maximum value in the SNORM range, 255 by default. |
|
inlinestaticnoexcept |
Computes the linear interpolation of two values.
p | The start value to interpolate. |
q | The end value to interpolate. |
time | The time of interpolation generally in the range [0.0, 1.0] . |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
Produces an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle.
angle | The angle in radians. |
-Math::OnePi
, Math::OnePi
].
|
inlinestatic |
|
inlinestaticconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
Converts a relative to an absolute epsilon, for the epsilon-equality check between two values.
L | The length type. |
T | value value type. |
Q | The GLM qualifier type. |
a | The first value. |
b | The second value. |
relativeEpsilon | The relative epsilon. |
|
inlinestaticconstexprnoexcept |
|
inlinestatic |
|
inlinestaticnoexcept |
Rounds a value down to the nearest integer, like floor
, except that if the value is very close to the higher integer it is rounded up (like ceil
) instead.
value | The value to round. |
tolerance | The tolerance. If the value is closer than this to the higher integer, it is rounded up instead. |
|
inlinestaticnoexcept |
Rounds a value up to the nearest integer, like ceil
, except that if the value is very close to the lower integer it is rounded down (like floor
) instead.
value | The value to round. |
tolerance | The tolerance. If the value is closer than this to the lower integer, it is rounded down instead. |
|
inlinestaticconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative.
This is similar to Math::sign except that returns 1.0 instead of 0.0 when the input value is 0.0.
value | The value to return the sign of. |
|
inlinestaticnoexcept |
Converts a scalar value in the range [-1.0, 1.0] to a SNORM in the range [0, rangeMaximum].
value | The scalar value in the range [-1.0, 1.0]. |
rangeMaximum | The maximum value in the mapped range, 255 by default. |
|
inlinestaticnoexcept |
Produces an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle.
angle | The angle in radians. |
Math::TwoPi
].