min(), max(), constrain(), map(), sq() and angle conversions.
More...
|
| #define | constrain(amt, low, high) |
| | Limits a value to a range: low if below it, high if above it.
|
| #define | sq(x) |
| | The square of a number, x * x.
|
| #define | radians(deg) |
| | Converts degrees to radians.
|
| #define | degrees(rad) |
| | Converts radians to degrees.
|
|
#define | PI 3.1415926535897932384626433832795 |
| | π, 3.14159...
|
|
#define | HALF_PI 1.5707963267948966192313216916398 |
| | π / 2.
|
|
#define | TWO_PI 6.283185307179586476925286766559 |
| | 2π.
|
|
#define | DEG_TO_RAD 0.017453292519943295769236907684886 |
| | Radians per degree, π / 180.
|
|
#define | RAD_TO_DEG 57.295779513082320876798154814105 |
| | Degrees per radian, 180 / π.
|
|
#define | EULER 2.718281828459045235360287471352 |
| | e, 2.71828...
|
|
| template<class T, class L> |
| auto | min (const T &a, const L &b) -> decltype((b< a) ? b :a) |
| | The smaller of two values.
|
| template<class T, class L> |
| auto | max (const T &a, const L &b) -> decltype((b< a) ? b :a) |
| | The larger of two values.
|
| long | map (long, long, long, long, long) |
| | Re-maps a number from one range to another, e.g. 0-1023 to 0-255.
|
min(), max(), constrain(), map(), sq() and angle conversions.
◆ constrain
| #define constrain |
( |
| amt, |
|
|
| low, |
|
|
| high ) |
Value:((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
Limits a value to a range: low if below it, high if above it.
- Note
- A macro: do not put x++ or a function call in the arguments.
◆ degrees
Value:
#define RAD_TO_DEG
Degrees per radian, 180 / π.
Definition Common.h:55
Converts radians to degrees.
◆ radians
Value:
#define DEG_TO_RAD
Radians per degree, π / 180.
Definition Common.h:54
Converts degrees to radians.
◆ sq
Value:
The square of a number, x * x.
- Note
- A macro: do not put x++ or a function call in the argument.
◆ map()
| long map |
( |
long | , |
|
|
long | , |
|
|
long | , |
|
|
long | , |
|
|
long | ) |
Re-maps a number from one range to another, e.g. 0-1023 to 0-255.
map(x, in_min, in_max, out_min, out_max). Integer maths: the result is rounded down and not limited to the output range (use constrain()).
- Returns
- The value in the output range.
◆ max()
template<class T, class L>
| auto max |
( |
const T & | a, |
|
|
const L & | b ) -> decltype((b< a) ? b :a) |
The larger of two values.
- Template Parameters
-
- Parameters
-
| a | First value. |
| b | Second value. |
- Returns
- b if a is less than it, otherwise a.
◆ min()
template<class T, class L>
| auto min |
( |
const T & | a, |
|
|
const L & | b ) -> decltype((b< a) ? b :a) |
The smaller of two values.
- Template Parameters
-
- Parameters
-
| a | First value. |
| b | Second value. |
- Returns
- b if it is less than a, otherwise a.