This repository contains two C# code files with a set of interfaces and classes for calculations on a sphere and for work with sphere triangular mesh.
The first file AleSpherical.cs provides interfaces ICartesian (vector), IGeoCoordinate (location on a sphere), classes implementing them, and static class SphericalExtension with extension methods for solving such geospatial tasks like finding a distance or azimuth from one point to another, checking if a point is inside a spherical polygon or belongs to a polyline, inflating a spherical polygon, building convex hull, calculating sunrise and sunset times (for the Earth), polyline encoding and decoding, etc. Learn more
The second file AleSphericalMesh.cs implements an icosahedron-based spherical subdivision mesh and cell indexing system. Mesh defines the 20 base icosahedron faces, methods to find the primary face for a location and to build compact 64-bit keys for cells at arbitrary subdivision levels (0 - 28). Keys encode face and quad-subdivision choices for fast geospatial indexing. The MeshCell structure represents a triangular cell (vertices, level, key) and provides subdivision, spatial tests, and utilities to cover geometric regions with cells. Learn more
AleSphericalGrid.cs has been moved to the v2 branch and kept for history.


