Skip to content

Commit

Permalink
Merge pull request #23 from CliMA/ncc/updates
Browse files Browse the repository at this point in the history
Some updates
  • Loading branch information
navidcy authored Jan 13, 2023
2 parents b05d705 + 1f54475 commit a1dd4dc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/cartesian_to_lat_lon.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""
cartesian_to_lat_lon(x, y, z)
Convert 3D coordinates `(x, y, z)` on the unit sphere to latitude-longitude `(lat, lon)`. Assumes `lat` is positive
with `z`, equatorial plane falls at ``z = 0`` and `lon` is measured anti-clockwise (eastward) from ``x``-axis (``y = 0``)
about the ``z``-axis.
This is a Julia translation of [MATLAB code from MITgcm](http://wwwcvs.mitgcm.org/viewvc/MITgcm/MITgcm_contrib/high_res_cube/matlab-grid-generator/map_xyz2lonlat.m?view=markup).
Convert 3D cartesian coordinates `(x, y, z)` on the unit sphere to latitude-longitude; method returns
a tuple `(latitude, longitude)` in degrees. The equatorial plane falls at ``z = 0``, latitude is the
angle measured from the equatorial plane, and longitude is measured anti-clockwise (eastward) from
``x``-axis (``y = 0``) about the ``z``-axis.
Examples
========
Expand All @@ -18,6 +17,9 @@ julia> cartesian_to_lat_lon(0, 0, 1)
julia> cartesian_to_lat_lon(√2/4, -√2/4, √3/2)
(59.99999999999999, -45.0)
julia> cartesian_to_lat_lon(-√6/4, √2/4, -√2/2)
(-45.00000000000001, 150.0)
```
"""
cartesian_to_lat_lon(x, y, z) = cartesian_to_latitude(x, y, z), cartesian_to_longitude(x, y, z)
Expand Down

0 comments on commit a1dd4dc

Please sign in to comment.