MathUtils

object MathUtils

General math-related and numeric utility functions.

Functions

Link copied to clipboard
fun distance(aX: Float, aY: Float, bX: Float, bY: Float): Float
fun distance(aX: Int, aY: Int, bX: Int, bY: Int): Float
Link copied to clipboard

Ends up being a bit faster than Math.round. This merely rounds its argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut differ slightly from Math.round in that half rounds down for negative values. -2.5 rounds to -3, not -2. For purposes here it makes no difference.