added NORMALIZE #define macro
avoids pointers and the accompanying dereference operations of normalize(...)pull/8/head
parent
6f78731d8f
commit
fcb9645dbe
|
@ -25,6 +25,14 @@ void normalize(float* xx, float* yy) {
|
|||
}
|
||||
}
|
||||
|
||||
#define NORMALIZE(_xx, _yy) \
|
||||
if(_xx != 0 || _yy != 0) { \
|
||||
const float m = sqrtf(_xx*_xx + _yy*_yy); \
|
||||
_xx /= m; _yy /= m; \
|
||||
} else { \
|
||||
_xx = 0; _yy = 0; \
|
||||
}
|
||||
|
||||
static inline
|
||||
int move_towards(float* out_x, float* out_y, float x, float y, float tx, float ty, float max_delta) {
|
||||
const float diff_x = tx - x,
|
||||
|
|
Loading…
Reference in New Issue