Spherical Geometry
A library for handling geometry on the surface of a sphere.
This library combines spherical and vector geometry to perform operations with points, great circles, great circle arcs... A great circle is an equivalent of a straight line in planar geometry - it is the shortest path between two points on a sphere.
Doing geometry on a sphere requires using spherical trigonometry and being very careful when taking arcsin etc. to get angles, as one often gets false results.
Examples
Below is an example of solving the GeCAA 2020 Theory task 7 analytically.
use ;
More examples are either in the documentation or the unit tests can well serve as ones.
Library state
The library is in active development, more features are expected to be added, see the table below for planned features. The API should not change much from the current state, but there are no guarantees.
State key:
- 🟢 - fully implemented
- 🟡 - partially implemented
- 🔴 - not yet implemented
| Feature | State |
|---|---|
| Points | 🟡 |
| Spherical ↔ Cartesian conversion | 🟢 |
| (Approximate) equality check | 🟢 |
| Distance between points (metric) | 🟢 |
| Distance between points (angular value) | 🔴 |
| Great circles | 🟡 |
| Construction from two points | 🟢 |
| Construction from an arc | 🟢 |
| Construction as a perpendicular to another circle (through a point) | 🔴 |
| Check if it contains a point | 🟢 |
| Intersections with other great circle | 🟢 |
| Great circle arcs | 🟡 |
| Construction from two points | 🟢 |
| Check if it contains a point | 🟢 |
| Intersection with great circle | 🟢 |
| Clamped intersection with great circle (returning the closest endpoint if no intersection is on the arc) | 🟢 |
| Intersection with another arc | 🔴 |
| Polygons | 🔴 |
| Construction from vertices | 🔴 |
| Check if it contains a point | 🔴 |