1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-22 07:45:29 +03:00

Fix setpoint rate sign, optimize code, cleanup from review

Also adds a `scaleRangef()` function to math.c
This commit is contained in:
Bruce Luckcuck 2018-06-27 19:27:22 -04:00
parent 0cd61c3a0f
commit 9b49d481e3
4 changed files with 37 additions and 53 deletions

View file

@ -176,6 +176,12 @@ int scaleRange(int x, int srcFrom, int srcTo, int destFrom, int destTo) {
return (a / b) + destFrom;
}
float scaleRangef(float x, float srcFrom, float srcTo, float destFrom, float destTo) {
float a = (destTo - destFrom) * (x - srcFrom);
float b = srcTo - srcFrom;
return (a / b) + destFrom;
}
// Normalize a vector
void normalizeV(struct fp_vector *src, struct fp_vector *dest)
{