Fix vector2angle
This commit is contained in:
parent
c2b56c583a
commit
5d4f17da3a
|
|
@ -307,9 +307,13 @@ RMAPI float Vector2DistanceSqr(Vector2 v1, Vector2 v2)
|
|||
}
|
||||
|
||||
// Calculate angle from two vectors
|
||||
// Parameters need to be normalized
|
||||
RMAPI float Vector2Angle(Vector2 v1, Vector2 v2)
|
||||
{
|
||||
float result = -acos(v1.x*v2.x + v1.y*v2.y);
|
||||
float dotProduct = v1.x*v2.x + v1.y*v2.y;
|
||||
|
||||
float t = dotProduct < -1 ? -1 : dotProduct;
|
||||
float result = acos(t > max ? max : t;);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user