---
title: "MTMath | Mobile sdk | Mobile sdk android | Android"
description: "MTMath"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# MTMath

object [MTMath](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/)

Pure math helpers for geographic calculations, projections, and tile indices.

Members

## Properties

[EARTH\_CIRCUMFERENCE](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/-e-a-r-t-h_-c-i-r-c-u-m-f-e-r-e-n-c-e/)

const val [EARTH\_CIRCUMFERENCE](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/-e-a-r-t-h_-c-i-r-c-u-m-f-e-r-e-n-c-e/): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Circumference of the Earth in meters.

[EARTH\_RADIUS](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/-e-a-r-t-h_-r-a-d-i-u-s/)

const val [EARTH\_RADIUS](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/-e-a-r-t-h_-r-a-d-i-u-s/): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html) = 6378137.0

Radius of the Earth in meters.

[MAX\_SAFE\_LATITUDE](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/-m-a-x_-s-a-f-e_-l-a-t-i-t-u-d-e/)

const val [MAX\_SAFE\_LATITUDE](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/-m-a-x_-s-a-f-e_-l-a-t-i-t-u-d-e/): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html) = 85.05112877980659

Maximum latitude used for Web Mercator calculations to prevent infinity.

## Functions

[circumferenceAtLatitude](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/circumference-at-latitude/)

fun [circumferenceAtLatitude](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/circumference-at-latitude/)(latitude: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Calculates the Earth's circumference at a given latitude in meters.

[haversineCumulatedDistanceWgs84](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/haversine-cumulated-distance-wgs84/)

fun [haversineCumulatedDistanceWgs84](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/haversine-cumulated-distance-wgs84/)(route: [List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)<[LngLat](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.map/-lng-lat/)\>): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Calculates the total cumulated distance of a route made of multiple WGS84 coordinates.

[haversineDistanceWgs84](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/haversine-distance-wgs84/)

fun [haversineDistanceWgs84](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/haversine-distance-wgs84/)(from: [LngLat](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.map/-lng-lat/), to: [LngLat](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.map/-lng-lat/)): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Calculates the great-circle distance between two WGS84 coordinates using the Haversine formula.

[haversineIntermediateWgs84](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/haversine-intermediate-wgs84/)

fun [haversineIntermediateWgs84](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/haversine-intermediate-wgs84/)(from: [LngLat](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.map/-lng-lat/), to: [LngLat](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.map/-lng-lat/), ratio: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)): [LngLat](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.map/-lng-lat/)

Computes an intermediate point between two WGS84 coordinates using the Haversine formula.

[latitudeToMercatorY](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/latitude-to-mercator-y/)

fun [latitudeToMercatorY](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/latitude-to-mercator-y/)(latitude: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Converts a latitude to Web Mercator Y coordinate in meters.

[latitudeToTileY](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/latitude-to-tile-y/)

fun [latitudeToTileY](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/latitude-to-tile-y/)(latitude: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html), zoom: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html), round: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = true): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Calculates the Web Mercator tile Y coordinate (XYZ scheme) for a given latitude and zoom level.

[longitudeToMercatorX](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/longitude-to-mercator-x/)

fun [longitudeToMercatorX](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/longitude-to-mercator-x/)(longitude: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Converts a longitude to Web Mercator X coordinate in meters.

[longitudeToTileX](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/longitude-to-tile-x/)

fun [longitudeToTileX](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/longitude-to-tile-x/)(longitude: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html), zoom: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html), round: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = true): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Calculates the Web Mercator tile X coordinate for a given longitude and zoom level.

[mercatorToWgs84](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/mercator-to-wgs84/)

fun [mercatorToWgs84](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/mercator-to-wgs84/)(x: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html), y: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)): [LngLat](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.map/-lng-lat/)

Converts a Web Mercator (X, Y) in meters to WGS84 coordinate.

[mercatorXToLongitude](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/mercator-x-to-longitude/)

fun [mercatorXToLongitude](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/mercator-x-to-longitude/)(x: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Converts a Web Mercator X coordinate in meters to longitude.

[mercatorYToLatitude](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/mercator-y-to-latitude/)

fun [mercatorYToLatitude](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/mercator-y-to-latitude/)(y: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Converts a Web Mercator Y coordinate in meters to latitude.

[toDegrees](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/to-degrees/)

fun [toDegrees](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/to-degrees/)(radians: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Converts radians to degrees.

[toRadians](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/to-radians/)

fun [toRadians](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/to-radians/)(degrees: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Converts degrees to radians.

[wgs84ToMercator](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/wgs84-to-mercator/)

fun [wgs84ToMercator](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/wgs84-to-mercator/)(coordinate: [LngLat](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.map/-lng-lat/)): [Pair](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html)<[Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html), [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)\>

Converts a WGS84 coordinate to Web Mercator (X, Y) in meters.

[wgs84ToTileIndex](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/wgs84-to-tile-index/)

fun [wgs84ToTileIndex](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/wgs84-to-tile-index/)(coordinate: [LngLat](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.map/-lng-lat/), zoom: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html), round: [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) = true): [Pair](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html)<[Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html), [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)\>

Converts a WGS84 coordinate to Web Mercator tile indices.

[wrapLongitude](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/wrap-longitude/)

fun [wrapLongitude](https://docs.maptiler.com/mobile-sdk/android/api/-map-tiler-s-d-k/com.maptiler.maptilersdk.helpers/-m-t-math/wrap-longitude/)(longitude: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)): [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)

Wraps a longitude value to be within the `[-180, 180]` range.
