|
static double | Clamp (const double &, const double &=0.0, const double &=1.0) |
| Clamp a double value between two bounds. More...
|
|
static int | Clamp (int, int=0, int=255) |
| Clamp an integer value between two bounds. More...
|
|
static double | Sqr (const double &) |
| Squares a double value. More...
|
|
static constexpr double | Cube (const double &) |
| Cubes a double value. More...
|
|
static double | Sqr4 (const double &) |
| Fourth power of a double value. More...
|
|
static double | SymmetricSqr (const double &) |
| Symmetric of square function over unit interval. More...
|
|
static double | Pow (const double &, const double &) |
| Power. More...
|
|
static double | Abs (const double &) |
| Absolute value. More...
|
|
static double | Sqrt32 (const double &) |
| Compute x3/2 as the square root of x3. More...
|
|
static double | Sqrt4 (const double &) |
| Compute the fourth root of x3. More...
|
|
static void | Powers (const double &, int, double *) |
| Compute the powers series of a real value 1, x, ... , xn-1. More...
|
|
static constexpr double | Mod (const double &, const double &) |
| Modulus for reals with negative values handled properly. More...
|
|
static double | Floor (const double &) |
| Floor function. More...
|
|
static double | Fract (const double &) |
| Fractional part of a real. More...
|
|
static double | FractFloor (const double &, double &) |
| Fractional part of a real. More...
|
|
static double | Ceil (const double &) |
| Ceil function. More...
|
|
static double | Min (const double &, const double &) |
| Minimum of two reals. More...
|
|
static double | Max (const double &, const double &) |
| Maximum of two reals. More...
|
|
static double | Min (const double &, const double &, const double &) |
| Minimum of three reals. More...
|
|
static double | Max (const double &, const double &, const double &) |
| Maximum of three reals. More...
|
|
static double | Min (const double &, const double &, const double &, const double &) |
| Minimum of four reals. More...
|
|
static double | Max (const double &, const double &, const double &, const double &) |
| Maximum of four reals. More...
|
|
static constexpr double | DegreeToRadian (const double &) |
| Convert degrees to randians. More...
|
|
static constexpr double | RadianToDegree (const double &) |
| Convert radian to degrees. More...
|
|
static constexpr double | Angle (int, int) |
| Compute 2 k π / n. More...
|
|
static constexpr double | Angle (const double &) |
| Angle strictly in [0,2 π[. More...
|
|
static double | ArcTan (const double &, const double &) |
| Inline version of the atan2() function.
|
|
static double | Step (double, double) |
| Step function. More...
|
|
static double | Cycloidal (const double &) |
| Sine wave over unit interval. More...
|
|
static double | Triangle (const double &) |
| Triangle wave over unit interval. More...
|
|
static double | Lerp (const double &, const double &, const double &) |
| Linear interpolation. More...
|
|
static double | Bilinear (const double &, const double &, const double &, const double &, const double &, const double &) |
| Bi-linear interpolation between four values. More...
|
|
static double | Trilinear (const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &) |
| Trilinear interpolation between eight values. More...
|
|
static double | Cubic (const double &, const double &, const double &, const double &, const double &) |
| Cubic Hermite interpolation. More...
|
|
static double | CubicPoints (const double &, const double &, const double &, const double &, const double &) |
| Cubic point interpolation. More...
|
|
static double | BiCubic (const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &=0.0, const double &=0.0, const double &=0.0, const double &=0.0) |
| Bi-cubic interpolation between four values, given partial derivatives. More...
|
|
static double | BiCubic (const double &, const double &, const double &, const double &, const double &, const double &) |
| Bi-cubic interpolation between four values, partial derivatives are implicitly defined as null. More...
|
|
static double | Sigmoid (const double &, const double &=1.0) |
| Sigmoid-like function. More...
|
|
static double | SigmoidQuadric (const double &) |
| Compactly supported sigmoid-like function implemented using a C1 piecewise symmetric quadric. More...
|
|
static double | Impulse (const double &, const double &=1.0) |
| Impulse function. More...
|
|
static double | Warp (const double &) |
| Unit interval warping function. More...
|
|
static double | Warp (const double &, const double &) |
| Unit interval gain function. More...
|
|
static bool | InRange (const double &, const double &, const double &, const double &) |
| Check if a values lies within a prescribed range. More...
|
|
static void | SetMinMax (const double &, double &, double &) |
| Update the minimum and maximum values given a double value. More...
|
|
static int | Integer (const double &) |
| Compute the integer part of a real. More...
|
|
static void | Sort (double &, double &) |
| Sort two reals. More...
|
|
static void | Sort (int &, int &) |
| Sort two integers. More...
|
|
static void | Sort (double &, double &, double &) |
| Sort three reals. More...
|
|
static void | Swap (double &, double &) |
| Swap two reals. More...
|
|
static void | Swap (int &, int &) |
| Swap two integers. More...
|
|
static bool | IsNumber (double) |
| Check if a real number is not NaN. More...
|
|
static bool | IsFinite (double) |
| Check if a real is not infinite. More...
|
|
static int | IntegerSign (const double &, const double &=0.0) |
| Compute the integer sign of a real. More...
|
|
static bool | SameSign (const double &, const double &) |
| Check if two reals have the same signs. More...
|
|
static bool | SameSign (const double &, const double &, const double &) |
| Check if three reals have the same signs. More...
|
|
static double | CopySign (const double &, const double &) |
| Composes a real with the magnitude of x and the sign of y. More...
|
|
static long | Binomial (int, int) |
| Calculate the Binomial coefficent. More...
|
|
static constexpr double | Unit (int, int) |
| Unit real value in [0,1] from two integers. More...
|
|
static double | Gaussian (const double &, const double &) |
| Gaussian. More...
|
|
static double | CompactGaussian (const double &, const double &) |
| Compact support Gaussian approximation. More...
|
|
static double | Fract (const double &, double &) |
| Compute integer and fractionnal parts. More...
|
|
static double | Fract (const double &, const double &, double &) |
| Compute integer and fractionnal parts. More...
|
|
static double | Fract (const double &, const double &, const double &, double &) |
| Compute integer and fractionnal parts given an interval. More...
|
|
static double | Geometric (double, int) |
| Compute the sum of the terms of a geometric series. More...
|
|
static void | Swap (double *&, double *&) |
| Swap two reals. More...
|
|
static void | Swap (int *&, int *&) |
| Swap two integers. More...
|
|
static void | BernsteinSeries (const double &, int, double *) |
| Compute the Bernstein terms.
|
|
static double | Bernstein (const double &, int, int) |
| Compute the i-th Bernstein term.
|
|
Core class implementing some useful functions and constants.
How can I use the constant Pi?
Simply use the static constant Math::Pi as follows:
static const double Pi
π.
Definition: mathematics.h:174
Note that in this case, you could also have used:
double Volume() const
Compute the volume of the sphere.
Definition: sphere.h:146
How many min/max functions have been implemented?
Up to four arguments are supported; for a larger number of arguments, a specific routine operating on an array should be written.
Is there a function to compute the square of a real sumber?
Use the following:
static double Sqr(const double &)
Squares a double value.
Definition: mathematics.h:335
For a Vector, use SquaredNorm(const Vector&);
Are there predefined square roots constants?
The sqrt function used not te be constexpr, so square roots of reals are not computed at compilation time. Some constants are provided, such as the following one:
static const double Sqrt3
Constant √3.
Definition: mathematics.h:181
What is the relative performance of mathematical functions such as square root or cosine?
The relative cost of commonly used mathematical functions is summarized in the following table.
Cost
Function | Cost |
+ - * fabs | 1 |
/ sqrt modf | ~4.8 |
/ sin cos | ~8.9 |
/ exp log | ~10.5 |
Math provides some functions such as Math::Sqrt32 or Math::Sqrt4 to avoid computationally intensive standard functions like pow:
static double Sqrt32(const double &)
Compute x3/2 as the square root of x3.
Definition: mathematics.h:349
How are implemented the step and smooth-step functions that are often used in procedural modeling? Different smoothing kernels, such as Cubic::Smooth(), are implented in odd-degree polynomials Cubic, Quintic and Septic. The corresponding step functions, such as Cubic::SmoothStep(), are also implemented.
- See also
- Linear::Step, Cubic::Smooth, Quintic::Smooth, Cubic::SmoothStep, Quintic::SmoothStep, Septic::SmoothStep.