#include <MathUtil.h>
Static Public Member Functions | |
| static bool | isAlmostEq (Real const x, Real const y) |
| True iff x is within eps of y. | |
| static bool | isAlmostZero (Real const x) |
| True iff x is within eps of zero. | |
| static int | round (Real const x) |
| Round x to the nearest integer value. | |
| static int | sgn (Real const x) |
| Return the sign of x. | |
| static Real | radToDeg (Real const t) |
| Return t in degrees. | |
| static Real | degToRad (Real const t) |
| Return t in radians. | |
| static Real | clamp (Real const x, Real lower, Real upper) |
| Clamp x to the closed range [lower, upper]. | |
| static Real | angleClamp (Real const t) |
| Clamp the angle t to the half-open range [-180, 180). | |
| static Real | uniform01 () |
| Uniformly pick a Real in the range [0, 1]. | |
| static int | uniform (int n) |
| Uniformly pick an integer in the range [0, n). | |
| static Real | normal (Real const mean=Real(0), Real const std=Real(1)) |
| Pick a Real according to the normal distribution with mean and standard deviation as provided. | |
| static Real | normalAngle (Real const mean=Real(0), Real const std=Real(70)) |
| Pick an angle (in degrees) according to an approximate normal distribution. | |
| Real tagGame::MathUtil::angleClamp | ( | Real const | t | ) | [inline, static] |
Clamp the angle t to the half-open range [-180, 180).
The range is half-open because the angle -180 is the same as the angle 180 and we only want one representation for an angle.
| Real tagGame::MathUtil::normalAngle | ( | Real const | mean = Real(0), |
|
| Real const | std = Real(70) | |||
| ) | [inline, static] |
Pick an angle (in degrees) according to an approximate normal distribution.
The normal distribution is only approximate because there is only finite support i.e. return value [-180,180]. But provided the std is less than about 70 degrees, then less than 1% of the probability mass would lie outside that range anyway.
1.5.1