This commit is contained in:
parent
4bb0043e21
commit
ff196f6557
|
@ -156,6 +156,17 @@ int findIndex2(const float array[], unsigned size, float value) {
|
||||||
return i || *array <= value ? i : -1;
|
return i || *array <= value ? i : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* in order to use binary search we need to know that axis elements are sorted
|
||||||
|
*/
|
||||||
|
void ensureArrayIsAscending(const char *msg, const float array[], int size) {
|
||||||
|
for (int i = 0; i < size - 1; i ++) {
|
||||||
|
if (array[i] >= array[i+ 1]) {
|
||||||
|
firmwareError(CUSTOM_ERR_6538, "invalid axis %s at %f", msg, array[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** @brief Binary search
|
/** @brief Binary search
|
||||||
* @returns the highest index within sorted array such that array[i] is greater than or equal to the parameter
|
* @returns the highest index within sorted array such that array[i] is greater than or equal to the parameter
|
||||||
* @note If the parameter is smaller than the first element of the array, -1 is returned.
|
* @note If the parameter is smaller than the first element of the array, -1 is returned.
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
int findIndex(const float array[], int size, float value);
|
int findIndex(const float array[], int size, float value);
|
||||||
int findIndexMsg(const char *msg, const float array[], int size, float value);
|
int findIndexMsg(const char *msg, const float array[], int size, float value);
|
||||||
|
void ensureArrayIsAscending(const char *msg, const float array[], int size);
|
||||||
int findIndex2(const float array[], unsigned size, float value);
|
int findIndex2(const float array[], unsigned size, float value);
|
||||||
float interpolate(float x1, float y1, float x2, float y2, float x);
|
float interpolate(float x1, float y1, float x2, float y2, float x);
|
||||||
float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, float x);
|
float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, float x);
|
||||||
|
|
Loading…
Reference in New Issue