mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Use Atan2 in CoordinateUtilities
This commit is contained in:
parent
2258dc3947
commit
38ac50652b
@ -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));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user