瀏覽代碼

Fix vector2angle (#2832)

* Fix vector2angle

* Fix ;

* use acosf

* need a break

* add comments
pull/2838/head
Antonis Geralis 2 年之前
committed by GitHub
父節點
當前提交
d1a104bba4
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 1 個檔案被更改,包括 7 行新增1 行删除
  1. +7
    -1
      src/raymath.h

+ 7
- 1
src/raymath.h 查看文件

@ -307,9 +307,15 @@ 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; // Dot product
float t = dotProduct < -1 ? -1 : dotProduct; // Clamp
if (t > 1) t = 1;
float result = acosf(t);
return result;
}

Loading…
取消
儲存