Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17ajf by
Math/Math.h@39:e128071a95b0, 2019-04-29 (annotated)
- Committer:
 - el17ajf
 - Date:
 - Mon Apr 29 16:30:47 2019 +0000
 - Revision:
 - 39:e128071a95b0
 - Parent:
 - 28:e09b7ac11dea
 
finished documenting all public methods;
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| el17ajf | 26:baa7077449e7 | 1 | #ifndef MATH_H | 
| el17ajf | 26:baa7077449e7 | 2 | #define MATH_H | 
| el17ajf | 26:baa7077449e7 | 3 | |
| el17ajf | 39:e128071a95b0 | 4 | /** | 
| el17ajf | 39:e128071a95b0 | 5 | * Namespace for maths-related helper functions | 
| el17ajf | 39:e128071a95b0 | 6 | */ | 
| el17ajf | 26:baa7077449e7 | 7 | namespace Math { | 
| el17ajf | 39:e128071a95b0 | 8 | /** | 
| el17ajf | 39:e128071a95b0 | 9 | * @brief lerp with a default value basically | 
| el17ajf | 39:e128071a95b0 | 10 | * a 'curried' lerp with t = 0.6 | 
| el17ajf | 39:e128071a95b0 | 11 | * @see lerp | 
| el17ajf | 39:e128071a95b0 | 12 | * @returns lerp(a, b, 0.6) | 
| el17ajf | 39:e128071a95b0 | 13 | */ | 
| el17ajf | 26:baa7077449e7 | 14 | int lerp(int a, int b); | 
| el17ajf | 39:e128071a95b0 | 15 | |
| el17ajf | 39:e128071a95b0 | 16 | /** | 
| el17ajf | 39:e128071a95b0 | 17 | * @brief Linear Interpolation, but works for ints | 
| el17ajf | 39:e128071a95b0 | 18 | * so you never lerp to the same value twice, the | 
| el17ajf | 39:e128071a95b0 | 19 | * minimum | a - b | is 1. | 
| el17ajf | 39:e128071a95b0 | 20 | * @param a The starting value (t = 0) | 
| el17ajf | 39:e128071a95b0 | 21 | * @param b The value when t = 1 | 
| el17ajf | 39:e128071a95b0 | 22 | * @param t The amount to interpolate | 
| el17ajf | 39:e128071a95b0 | 23 | * @returns a * (t - 1) + b * t | 
| el17ajf | 39:e128071a95b0 | 24 | */ | 
| el17ajf | 28:e09b7ac11dea | 25 | int lerp(int a, int b, double t); | 
| el17ajf | 26:baa7077449e7 | 26 | } | 
| el17ajf | 26:baa7077449e7 | 27 | |
| el17ajf | 26:baa7077449e7 | 28 | #endif | 
