Companion

object Companion

Properties

Link copied to clipboard
Link copied to clipboard

multiply by this to convert from degrees to radians

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val E: Float = 2.7182817f
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val PI: Float = 3.1415927f
Link copied to clipboard
val PI2: Float
Link copied to clipboard
Link copied to clipboard

multiply by this to convert from radians to degrees

Link copied to clipboard

Functions

Link copied to clipboard
fun atan2(y: Float, x: Float): Float

Returns atan2 in radians, faster but less accurate than Math.atan2. Average error of 0.00231 radians (0.1323 degrees), largest error of 0.00488 radians (0.2796 degrees).

Link copied to clipboard
fun ceil(value: Float): Int

Returns the smallest integer greater than or equal to the specified float. This method will only properly ceil floats from -(2^14) to (Float.MAX_VALUE - 2^14).

Link copied to clipboard
fun ceilPositive(value: Float): Int

Returns the smallest integer greater than or equal to the specified float. This method will only properly ceil floats that are positive.

Link copied to clipboard
fun cos(radians: Float): Float

Returns the cosine in radians from a lookup table.

Link copied to clipboard
fun cosDeg(degrees: Float): Float

Returns the cosine in radians from a lookup table.

Link copied to clipboard
fun dpToPx(dp: Float): Float
fun dpToPx(dp: Int): Int
Link copied to clipboard
fun floor(value: Float): Int

Returns the largest integer less than or equal to the specified float. This method will only properly floor floats from -(2^14) to (Float.MAX_VALUE - 2^14).

Link copied to clipboard
fun floorPositive(value: Float): Int

Returns the largest integer less than or equal to the specified float. This method will only properly floor floats that are positive. Note this method simply casts the float to int.

Link copied to clipboard
fun interpolateBetween(value: Float, min: Float, max: Float): Float
Link copied to clipboard
fun isEqual(a: Float, b: Float): Boolean

Returns true if a is nearly equal to b. The function uses the default floating error tolerance.

fun isEqual(a: Float, b: Float, tolerance: Float): Boolean

Returns true if a is nearly equal to b.

Link copied to clipboard
fun isPowerOfTwo(value: Int): Boolean
Link copied to clipboard
fun isZero(value: Float): Boolean

Returns true if the value is zero (using the default tolerance as upper bound)

fun isZero(value: Float, tolerance: Float): Boolean

Returns true if the value is zero.

Link copied to clipboard
fun lerp(fromValue: Float, toValue: Float, progress: Float): Float

Linearly interpolates between fromValue to toValue on progress position.

Link copied to clipboard
fun lerpAngle(fromRadians: Float, toRadians: Float, progress: Float): Float

Linearly interpolates between two angles in radians. Takes into account that angles wrap at two pi and always takes the direction with the smallest delta angle.

Link copied to clipboard
fun lerpAngleDeg(fromDegrees: Float, toDegrees: Float, progress: Float): Float

Linearly interpolates between two angles in degrees. Takes into account that angles wrap at 360 degrees and always takes the direction with the smallest delta angle.

Link copied to clipboard
fun log(a: Float, value: Float): Float
Link copied to clipboard
fun log2(value: Float): Float
Link copied to clipboard
fun nearestNumber(number: Float, vararg numbers: Float): Float
Link copied to clipboard
fun nextPowerOfTwo(value: Int): Int

Returns the next power of two. Returns the specified value if the value is already a power of two.

Link copied to clipboard
fun pxToDp(px: Float): Float
fun pxToDp(px: Int): Int
Link copied to clipboard
fun randInt(min: Int, max: Int): Int

Returns a pseudo-random number between min and max, inclusive. The difference between min and max can be at most Integer.MAX_VALUE - 1.

Link copied to clipboard
fun random(): Float

Returns random number between 0.0 (inclusive) and 1.0 (exclusive).

fun random(range: Float): Float

Returns a random number between 0 (inclusive) and the specified value (exclusive).

fun random(range: Int): Int
fun random(range: Long): Long

Returns a random number between 0 (inclusive) and the specified value (inclusive).

fun random(start: Float, end: Float): Float

Returns a random number between start (inclusive) and end (exclusive).

fun random(start: Int, end: Int): Int
fun random(start: Long, end: Long): Long

Returns a random number between start (inclusive) and end (inclusive).

Link copied to clipboard

Returns a random boolean value.

Returns true if a random value between 0 and 1 is less than the specified value.

Link copied to clipboard
fun randomRange(start: Float, end: Float): Float
Link copied to clipboard

Returns -1 or 1, randomly.

Link copied to clipboard

Returns a triangularly distributed random number between -1.0 (exclusive) and 1.0 (exclusive), where values around zero are more likely.

Returns a triangularly distributed random number between -max (exclusive) and max (exclusive), where values around zero are more likely.

fun randomTriangular(min: Float, max: Float, mode: Float = (min + max) * 0.5f): Float

Returns a triangularly distributed random number between min (inclusive) and max (exclusive), where values around mode are more likely.

Link copied to clipboard
fun round(value: Float): Int

Returns the closest integer to the specified float. This method will only properly round floats from -(2^14) to (Float.MAX_VALUE - 2^14).

Link copied to clipboard
fun roundPositive(value: Float): Int

Returns the closest integer to the specified float. This method will only properly round floats that are positive.

Link copied to clipboard
Link copied to clipboard
fun sin(radians: Float): Float

Returns the sine in radians from a lookup table.

Link copied to clipboard
fun sinDeg(degrees: Float): Float

Returns the sine in radians from a lookup table.