Merge pull request #1 from veins1/veins1-patch-1
Vector2Angle fix for non-normalized vectors
This commit is contained in:
commit
a1ffb55eb8
|
|
@ -309,7 +309,9 @@ RMAPI float Vector2DistanceSqr(Vector2 v1, Vector2 v2)
|
||||||
// Calculate angle from two vectors
|
// Calculate angle from two vectors
|
||||||
RMAPI float Vector2Angle(Vector2 v1, Vector2 v2)
|
RMAPI float Vector2Angle(Vector2 v1, Vector2 v2)
|
||||||
{
|
{
|
||||||
float result = -acos(v1.x*v2.x + v1.y*v2.y);
|
float v1Length = sqrtf((v1.x*v1.x) + (v1.y*v1.y));
|
||||||
|
float v2Length = sqrtf((v2.x*v2.x) + (v2.y*v2.y));
|
||||||
|
float result = -acos((v1.x*v2.x + v1.y*v2.y)/(v1Length*v2Length));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user