|
static double | Clamp (const double &, const double &=0.0, const double &=1.0) |
| Array of binomial coefficients.
|
|
static int | Clamp (int, int=0, int=255) |
| Clamp an integer value between two bounds.
|
|
static constexpr double | Sqr (const double &) |
| Squares a double value.
|
|
static constexpr double | Cube (const double &) |
| Cubes a double value.
|
|
static double | Sqr4 (const double &) |
| Fourth power of a double value.
|
|
static double | SymmetricSqr (const double &) |
| Symmetric of square function over unit interval.
|
|
static double | Pow (const double &, const double &) |
| Power.
|
|
static double | Abs (const double &) |
| Absolute value.
|
|
static double | Sqrt32 (const double &) |
| Compute x3/2 as the square root of x3.
|
|
static double | Sqrt4 (const double &) |
| Compute the fourth root of x3.
|
|
static void | Powers (const double &, int, double *) |
| Compute the powers series of a real value 1, x, ... , xn-1.
|
|
static void | Powers (const double &, int, double *, double *) |
| Compute the powers series of a real value 1, x, ... , xn-1 and 1, 1-x, ... , (1-x)n-1.
|
|
static constexpr double | Mod (const double &, const double &) |
| Modulus for reals with negative values handled properly.
|
|
static double | Floor (const double &) |
| Floor function.
|
|
static double | Fract (const double &) |
| Fractional part of a real.
|
|
static double | FractFloor (const double &, double &) |
| Fractional part of a real.
|
|
static double | Ceil (const double &) |
| Ceil function.
|
|
static double | Min (const double &, const double &) |
| Minimum of two reals.
|
|
static double | Max (const double &, const double &) |
| Maximum of two reals.
|
|
static double | Min (const double &, const double &, const double &) |
| Minimum of three reals.
|
|
static double | Max (const double &, const double &, const double &) |
| Maximum of three reals.
|
|
static double | Min (const double &, const double &, const double &, const double &) |
| Minimum of four reals.
|
|
static double | Max (const double &, const double &, const double &, const double &) |
| Maximum of four reals.
|
|
static constexpr double | DegreeToRadian (const double &) |
| Convert degrees to randians.
|
|
static constexpr double | RadianToDegree (const double &) |
| Convert radian to degrees.
|
|
static constexpr double | Angle (int, int) |
| Compute 2 k π / n.
|
|
static constexpr double | Angle (const double &) |
| Angle strictly in [0,2 π[.
|
|
static double | AngleNorm (const double &, const double &) |
| Compute the (positive) angle distance between two angles.
|
|
static double | AngleSigned (const double &, const double &) |
| Compute the signed angle norm between two angles.
|
|
static double | AngleLerp (const double &, const double &, const double &) |
| Compute the interpolation between two angles, using the smallest angle rotation.
|
|
static double | ArcTan (const double &, const double &) |
| Inline version of the atan2() function.
|
|
static double | FoldAngle (const double &, bool=true) |
| Fold the argument angle to [0,2 π[ or [- π;pi[.
|
|
static double | SinAtan (const double &) |
| Trigonometric simplification of sin(atan(x)).
|
|
static double | CosAtan (const double &) |
| Trigonometric simplification of cos(atan(x)).
|
|
static double | Step (double, double) |
| Step function.
|
|
static double | Cycloidal (const double &) |
| Sine wave over unit interval.
|
|
static double | Triangle (const double &) |
| Triangle wave over unit interval.
|
|
static double | Lerp (const double &, const double &, const double &) |
| Linear interpolation.
|
|
static double | Bilinear (const double &, const double &, const double &, const double &, const double &, const double &) |
| Bi-linear interpolation between four values.
|
|
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.
|
|
static double | Cubic (const double &, const double &, const double &, const double &, const double &) |
| Cubic Hermite interpolation.
|
|
static double | CubicPoints (const double &, const double &, const double &, const double &, const double &) |
| Cubic point interpolation.
|
|
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.
|
|
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.
|
|
static double | Sigmoid (const double &, const double &=1.0) |
| Sigmoid-like function.
|
|
static double | SigmoidQuadric (const double &) |
| Compactly supported sigmoid-like function implemented using a C1 piecewise symmetric quadric.
|
|
static double | Impulse (const double &, const double &=1.0) |
| Impulse function.
|
|
static double | Warp (const double &) |
| Unit interval warping function.
|
|
static double | Warp (const double &, const double &) |
| Unit interval gain function.
|
|
static bool | InRange (const double &, const double &, const double &, const double &) |
| Check if a values lies within a prescribed range.
|
|
static void | SetMinMax (const double &, double &, double &) |
| Update the minimum and maximum values given a double value.
|
|
static int | Integer (const double &) |
| Compute the integer part of a real.
|
|
static void | Sort (int &, int &) |
| Sort two integers.
|
|
static void | Sort (double &, double &) |
| Sort two reals.
|
|
static void | Sort (double &, double &, double &) |
| Sort three reals.
|
|
static void | Sort (double &, double &, double &, double &) |
| Sort four reals, with a maximum of 5 comparisons.
|
|
static void | Sort5 (double *) |
|
static void | Swap (int &, int &) |
| Swap two integers.
|
|
static void | Swap (double &, double &) |
| Swap two reals.
|
|
static bool | IsNumber (double) |
| Check if a real number is not NaN.
|
|
static bool | IsFinite (double) |
| Check if a real is not infinite.
|
|
static int | IntegerSign (const double &, const double &=0.0) |
| Compute the integer sign of a real.
|
|
static bool | SameSign (const double &, const double &) |
| Check if two reals have the same signs.
|
|
static bool | SameSign (const double &, const double &, const double &) |
| Check if three reals have the same signs.
|
|
static double | CopySign (const double &, const double &) |
| Composes a real with the magnitude of x and the sign of y.
|
|
static double | Sign (const double &) |
| Returns +1 or -1 depending on the sign of argument.
|
|
static long | Binomial (int, int) |
| Calculate the Binomial coefficent.
|
|
static constexpr double | Unit (int, int) |
| Unit real value in [0,1] from two integers.
|
|
static double | Gaussian (const double &, const double &) |
| Gaussian.
|
|
static double | GaussianProbability (const double &, const double &) |
| Gaussian probability density function.
|
|
static double | CompactGaussian (const double &, const double &) |
| Compact support Gaussian approximation.
|
|
static double | Fract (const double &, double &) |
| Compute integer and fractionnal parts.
|
|
static double | Fract (const double &, const double &, double &) |
| Compute integer and fractionnal parts.
|
|
static double | Fract (const double &, const double &, const double &, double &) |
| Compute integer and fractionnal parts given an interval.
|
|
static double | Geometric (double, int) |
| Compute the sum of the terms of a geometric series.
|
|
static void | Swap (double *&, double *&) |
| Swap two reals.
|
|
static void | Swap (int *&, int *&) |
| Swap two integers.
|
|
static void | BernsteinSeries (const double &, int, double *) |
| Compute the Bernstein terms.
|
|
static double | Bernstein (const double &, int, int) |
| Compute the i-th Bernstein term.
|
|
static double | SmoothingCubic (double, double, double) |
| Generalized C2 polynomial smoothing function between two distances.
|
|
static double | SmoothingQuadric (double, double, double) |
| Generalized C1 polynomial smoothing function between two distances.
|
|
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 constexpr double Pi
π.
Definition mathematics.h:178
Note that in this case, you could also have used:
double Volume() const
Compute the volume of the sphere.
Definition sphere.h:147
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 constexpr double Sqr(const double &)
Squares a double value.
Definition mathematics.h:381
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 constexpr double Sqrt3
Constant √3.
Definition mathematics.h:185
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:404
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.