mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-01-21 13:58:25 -05:00
Used IntelliJ IDEA's linter to perform code cleanup. There were unused variables, `var` that could be replaced with `val`, and other minor code style issues. While doing this, I also discovered that a lot of documentation links were broken. The fix is to stop intenting the text after a `@param`.
1.6 KiB
1.6 KiB
//astronomy/io.github.cosinekitty.astronomy/Vector/toHorizontal
toHorizontal
fun toHorizontal(refraction: Refraction): Spherical
Converts Cartesian coordinates to horizontal coordinates.
Given a horizontal Cartesian vector, returns horizontal azimuth and altitude. IMPORTANT: This function differs from Vector.toSpherical in two ways:
- toSpherical returns a lon value that represents azimuth defined counterclockwise from north (e.g., west = +90), but this function represents a clockwise rotation (e.g., east = +90). The difference is because toSpherical is intended to preserve the vector "right-hand rule", while this function defines azimuth in a more traditional way as used in navigation and cartography.
- This function optionally corrects for atmospheric refraction, while toSpherical does not.
The returned object contains the azimuth in lon. It is measured in degrees clockwise from north: east = +90 degrees, west = +270 degrees.
The altitude is stored in lat.
The distance to the observed object is stored in dist, and is expressed in astronomical units (AU).
Parameters
| refraction | Refraction.None: no atmospheric refraction correction is performed. Refraction.Normal: correct altitude for atmospheric refraction. Refraction.JplHor: for JPL Horizons compatibility testing only; not recommended for normal use. |