Skip to content

Commit

Permalink
Fix vec2_norm
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Sep 10, 2024
1 parent 8230084 commit 5888392
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sources/iron_vec2.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ float vec2_cross(vec2_t a, vec2_t b) {
}

vec2_t vec2_norm(vec2_t v) {
float length = vec2_len(v);
v.x /= length;
v.y /= length;
float n = vec2_len(v);
if (n > 0.0) {
float inv_n = 1.0f / n;
v.x *= inv_n;
v.y *= inv_n;
}
return v;
}

Expand Down

0 comments on commit 5888392

Please sign in to comment.