normalize will now normalize if either x or y is non-zero

previously 100,0 would return 100,0 instead of 1,0
pull/8/head
Sara 2023-06-18 16:33:39 +02:00
parent 494dbfedb3
commit 6f78731d8f
1 changed files with 1 additions and 1 deletions

View File

@ -18,7 +18,7 @@ void clamp_magnitude(float* xx, float* yy, float max_magnitude) {
static inline static inline
void normalize(float* xx, float* yy) { void normalize(float* xx, float* yy) {
float x = *xx, y = *yy; float x = *xx, y = *yy;
if(x != 0 && y != 0) { if(x != 0 || y != 0) {
const float m = sqrtf(x*x + y*y); const float m = sqrtf(x*x + y*y);
x /= m; y /= m; x /= m; y /= m;
*xx = x; *yy = y; *xx = x; *yy = y;