SloppyMath

object SloppyMath

Math functions that trade off accuracy for speed.

Functions

Link copied to clipboard
fun asin(a: Double): Double

Returns the arc sine of a value.

Link copied to clipboard
fun cos(a: Double): Double

Returns the trigonometric cosine of an angle.

Link copied to clipboard

Returns the Haversine distance in meters between two points given the previous result from .haversinSortKey

fun haversinMeters(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double

Returns the Haversine distance in meters between two points specified in decimal degrees (latitude/longitude). This works correctly even if the dateline is between the two points.

Link copied to clipboard
fun haversinSortKey(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double

Returns a sort key for distance. This is less expensive to compute than .haversinMeters, but it always compares the same. This can be converted into an actual distance with .haversinMeters, which effectively does the second half of the computation.