Use Atan2 in CoordinateUtilities

This commit is contained in:
Nick 2022-07-14 17:42:03 -04:00
parent 2258dc3947
commit 38ac50652b

View File

@ -25,9 +25,7 @@ namespace NewHorizons.Utility
float dist = Mathf.Sqrt(x * x + y * y + z * z); float dist = Mathf.Sqrt(x * x + y * y + z * z);
// theta // theta
float longitude = 180f; var longitude = Mathf.Rad2Deg * Mathf.Atan2(y, x);
if (x > 0) longitude = Mathf.Rad2Deg * Mathf.Atan(y / x);
if (x < 0) longitude = Mathf.Rad2Deg * (Mathf.Atan(y / x) + Mathf.PI);
// phi // phi
float latitude = (Mathf.Rad2Deg * Mathf.Acos(z / dist)); float latitude = (Mathf.Rad2Deg * Mathf.Acos(z / dist));