Mathematical definitions and functions.
More...
|
#define | PI 3.1415926535897932384626433832795 |
| A constant representing the ratio of a circle's circumference to its diameter.
|
|
#define | HALF_PI 1.5707963267948966192313216916398 |
| A constant representing half of the mathematical constant π (pi) in programming and mathematics.
|
|
#define | TWO_PI 6.283185307179586476925286766559 |
| A constant representing two times the mathematical constant π (pi) in programming and mathematics.
|
|
#define | DEG_TO_RAD 0.017453292519943295769236907684886 |
| A constant for converting degrees to radians in mathematics and programming applications.
|
|
#define | RAD_TO_DEG 57.295779513082320876798154814105 |
| A constant for converting radians to degrees in mathematical and programming contexts.
|
|
#define | EULER 2.718281828459045235360287471352 |
| Euler's constant.
|
|
#define | min(a, b) ((a)<(b)?(a):(b)) |
| Returns the smaller of two values. More...
|
|
#define | max(a, b) ((a)>(b)?(a):(b)) |
| Returns the larger of two values. More...
|
|
#define | constrain(amt, low, high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) |
| Constrains a value to be within a specified range. More...
|
|
#define | radians(deg) ((deg)*DEG_TO_RAD) |
| Converts degrees to radians. More...
|
|
#define | degrees(rad) ((rad)*RAD_TO_DEG) |
| Converts radians to degrees. More...
|
|
#define | sq(x) ((x)*(x)) /* x^2 */ |
| Squares a number. More...
|
|
|
long | map (long x, long in_min, long in_max, long out_min, long out_max) |
| Maps a value from one range to another. More...
|
|
Mathematical definitions and functions.
◆ constrain
#define constrain |
( |
|
amt, |
|
|
|
low, |
|
|
|
high |
|
) |
| ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) |
Constrains a value to be within a specified range.
- Parameters
-
amt | The value to constrain. |
low | The lower end of the range. |
high | The upper end of the range. |
- Returns
- The constrained value.
◆ degrees
Converts radians to degrees.
- Parameters
-
- Returns
- The angle in degrees.
◆ max
#define max |
( |
|
a, |
|
|
|
b |
|
) |
| ((a)>(b)?(a):(b)) |
Returns the larger of two values.
- Parameters
-
a | First value. |
b | Second value. |
- Returns
- The larger of the two values.
◆ min
#define min |
( |
|
a, |
|
|
|
b |
|
) |
| ((a)<(b)?(a):(b)) |
Returns the smaller of two values.
- Parameters
-
a | First value. |
b | Second value. |
- Returns
- The smaller of the two values.
◆ radians
Converts degrees to radians.
- Parameters
-
- Returns
- The angle in radians.
◆ sq
#define sq |
( |
|
x | ) |
((x)*(x)) /* x^2 */ |
Squares a number.
- Parameters
-
- Returns
- The squared value.
◆ map()
long map |
( |
long |
x, |
|
|
long |
in_min, |
|
|
long |
in_max, |
|
|
long |
out_min, |
|
|
long |
out_max |
|
) |
| |
Maps a value from one range to another.
- Parameters
-
x | The value to map. |
in_min | The lower bound of the input range. |
in_max | The upper bound of the input range. |
out_min | The lower bound of the output range. |
out_max | The upper bound of the output range. |
- Returns
- The mapped value.
- See also
- https://www.arduino.cc/reference/en/language/functions/math/map