浏览代码
Fix inverse length in Vector2Normalize (#2189)
Following the pattern in Vector3Normalize.
pull/2194/head
HarriP
3 年前
committed by
GitHub
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有
1 个文件被更改,包括
3 次插入 和
2 次删除
-
src/raymath.h
|
|
@ -328,8 +328,9 @@ RMAPI Vector2 Vector2Normalize(Vector2 v) |
|
|
|
|
|
|
|
if (length > 0) |
|
|
|
{ |
|
|
|
result.x = v.x*1.0f/length; |
|
|
|
result.y = v.y*1.0f/length; |
|
|
|
float ilength = 1.0f / length; |
|
|
|
result.x = v.x * ilength; |
|
|
|
result.y = v.y * ilength; |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|