package io.rtron.math.std

Fields

Name Description
val DBL_EPSILON: Double
val DBL_EPSILON_1: Double
val DBL_EPSILON_2: Double
val DBL_EPSILON_3: Double
val DBL_EPSILON_4: Double
val DBL_EPSILON_5: Double
val DBL_EPSILON_6: Double
val DBL_EPSILON_7: Double
val DBL_EPSILON_8: Double
val DBL_EPSILON_9: Double
val DBL_EPSILON_10: Double
val FLT_EPSILON: Float
val DEFAULT_TOLERANCE: Double
const PI: /** Value of PI as double. (180 degrees) */

Value of PI as double. (180 degrees)

const TWO_PI: /** Value of 2PI as double. (360 degrees) */

Value of 2PI as double. (360 degrees)

const HALF_PI: /** Value of PI/2 as double. (90 degrees) */

Value of PI/2 as double. (90 degrees)

const QUARTER_PI: /** Value of PI/4 as double. (45 degrees) */

Value of PI/4 as double. (45 degrees)

const INV_PI: /** Value of 1/PI as double. */

Value of 1/PI as double.

const INV_TWO_PI: /** Value of 1/(2PI) as double. */

Value of 1/(2PI) as double.

const DEG_TO_RAD: /** Value to multiply a degree value by, to convert to radians. */

Value to multiply a degree value by, to convert to radians.

const RAD_TO_DEG: /** Value to multiply a radian value by, to convert to degrees. */

Value to multiply a radian value by, to convert to degrees.

Methods

fuzzyEquals

fun fuzzyEquals(a: Double, b: Double, tolerance: Double): Boolean

Returns if a equals b with a defined tolerance.

Parameters

Name Description
a: Double

first value

b: Double

second value

tolerance: Double

allowed tolerance

ReturnValue

Name Description
Boolean

true, if abs(a - b) <= tolerance

fuzzyCompare

fun fuzzyCompare(a: Double, b: Double, tolerance: Double): (a: Double, b: Double, tolerance: Double)

Returns the comparison of a and b with a defined tolerance.

Parameters

Name Description
a: Double

first value

b: Double

second value

tolerance: Double

allowed tolerance

ReturnValue

Name Description
(a: Double, b: Double, tolerance: Double)

0 for a fuzzyEquals b; -1 for a < b; 1 for a > b

fuzzyLessThanOrEquals

fun fuzzyLessThanOrEquals(a: Double, b: Double, tolerance: Double): Boolean

Returns true, if a <= b with a tolerance.

Parameters

Name Description
a: Double

first value

b: Double

second value

tolerance: Double

allowed tolerance

ReturnValue

Name Description
Boolean

true, if a <= b with a tolerance; false otherwise

fuzzyMoreThanOrEquals

fun fuzzyMoreThanOrEquals(a: Double, b: Double, tolerance: Double): Boolean

Returns true, if a >= b with a tolerance.

Parameters

Name Description
a: Double

first value

b: Double

second value

tolerance: Double

allowed tolerance

ReturnValue

Name Description
Boolean

true, if a >= b with a tolerance; false otherwise

normalizeAngle

fun normalizeAngle(angle: Double, center: Double): (angle: Double, center: Double = PI)

Normalizes an angle around the center.

Parameters

Name Description
angle: Double

angle for normalization in radians

center: Double

center of the desired normalization interval

ReturnValue

Name Description
(angle: Double, center: Double = PI)

normalized angle

sign

fun sign(x: Int): Int

Returns the signum of an integer x.

Parameters

Name Description
x: Int

the value whose sign is to be computed

ReturnValue

Name Description
Int

-1, if x is negative; 0, if x is zero; +1, if x is positive

reshapeByColumnDimension

fun DoubleArray.reshapeByColumnDimension(columnDimension: Int): Array<DoubleArray>

Reshapes a DoubleArray towards a matrix with a defined columnDimension.

Receiver

Name Description
DoubleArray

Parameters

Name Description
columnDimension: Int

number of columns or size of returned DoubleArray, respectively

ReturnValue

Name Description
Array<DoubleArray>

matrix represented as an Array (columns) of DoubleArray (rows)

reshapeByRowDimension

fun DoubleArray.reshapeByRowDimension(rowDimension: Int): Array<DoubleArray>

Reshapes a DoubleArray towards a matrix with a defined rowDimension.

Receiver

Name Description
DoubleArray

Parameters

Name Description
rowDimension: Int

number of rows or size of returned Array, respectively

ReturnValue

Name Description
Array<DoubleArray>

matrix represented as an Array (columns) of DoubleArray (rows)