Skip to content

Commit 3419aef

Browse files
authored
Fix Vector2Angle() (#2829)
With this fix the function still returns negative values, which is wrong. But we keep this behaviour to maintain backwards compatibility.
1 parent 445ce51 commit 3419aef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/raymath.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ RMAPI float Vector2DistanceSqr(Vector2 v1, Vector2 v2)
309309
// Calculate angle from two vectors
310310
RMAPI float Vector2Angle(Vector2 v1, Vector2 v2)
311311
{
312-
float result = atan2f(v2.y, v2.x) - atan2f(v1.y, v1.x);
312+
float result = -acos(v1.x*v2.x + v1.y*v2.y);
313313

314314
return result;
315315
}

0 commit comments

Comments
 (0)