MathUtils

Numeric and geometry helpers retained by the recovered baselite API.

Properties

Link copied to clipboard
const val FLOAT_ONE: Float = 1.0f

Floating-point representation of one.

Functions

Link copied to clipboard
fun <T : Comparable<T>> T.atLeast(min: T): T

Returns this value or min, whichever is larger.

Link copied to clipboard
fun <T : Comparable<T>> T.atMost(max: T): T

Returns this value or max, whichever is smaller.

Link copied to clipboard
fun clamp(value: Int, min: Int, max: Int): Int

Returns value constrained to the inclusive range from min to max.

Link copied to clipboard
fun distance(x1: Float, y1: Float, x2: Float, y2: Float): Double

Returns the Euclidean distance between (x1, y1) and (x2, y2).

Link copied to clipboard

Returns true when matrix is null or represents the identity transform.

Link copied to clipboard
fun Float.limitIn(start: Float, end: Float, startPadding: Float = 0.0f, endPadding: Float = 0.0f): Float

Constrains this value to the inclusive interval between start and end, inset by the supplied paddings.

Link copied to clipboard
fun lineNearAngle(x1: Float, y1: Float, x2: Float, y2: Float): Float

Returns how far the line from (x1, y1) to (x2, y2) is from its nearest horizontal or vertical axis, in degrees from 0 through 45.

Link copied to clipboard

Normalizes angle to [0, 360) and returns the zero-based ten-degree bucket from 0 to 35.

Link copied to clipboard

Returns str as a float, or 0.0 when it is malformed.

fun parseFloat(str: String?, defaultValue: Float): Float

Returns str as a float, or defaultValue when it is null or malformed.