For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.
MTMath
Pure math helpers for geographic calculations, projections, and tile indices.
Properties
Functions
Calculates the Earth's circumference at a given latitude in meters.
Calculates the total cumulated distance of a route made of multiple WGS84 coordinates.
Calculates the great-circle distance between two WGS84 coordinates using the Haversine formula.
Computes an intermediate point between two WGS84 coordinates using the Haversine formula.
Converts a latitude to Web Mercator Y coordinate in meters.
Calculates the Web Mercator tile Y coordinate (XYZ scheme) for a given latitude and zoom level.
Converts a longitude to Web Mercator X coordinate in meters.
Calculates the Web Mercator tile X coordinate for a given longitude and zoom level.
Converts a Web Mercator (X, Y) in meters to WGS84 coordinate.
Converts a Web Mercator X coordinate in meters to longitude.
Converts a Web Mercator Y coordinate in meters to latitude.
Converts a WGS84 coordinate to Web Mercator (X, Y) in meters.
Wraps a longitude value to be within the [-180, 180] range.