Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
open class Angle(val suffix: String, val ratio: Double = 1.0) : Units

Units to measure geometric angles.

Link copied to clipboard
class BinarySize(val suffix: String, val ratio: Double = 1.0) : Units

Units to measure computer storage, bandwidth, etc..

Link copied to clipboard
typealias Distance = Length
Link copied to clipboard
open class GraphicsLength(val suffix: String, val ratio: Double = 1.0) : Units

Units for measuring graphics display distances (i.e. distances on the surface of a display).

Link copied to clipboard
class InverseUnits<T : Units>(val unit: T) : Units

The inverse of a given Units.

Link copied to clipboard
open class Length(val suffix: String, val ratio: Double = 1.0) : Units

Units for length or distance.

Link copied to clipboard
open class Mass(val suffix: String, val ratio: Double = 1.0) : Units

Units to measure how much matter is in an object.

Link copied to clipboard
class Measure<T : Units>(val amount: Double, val units: T) : Comparable<Measure<T>>

A quantity with a unit type.

Link copied to clipboard
typealias Square<T> = UnitsProduct<T, T>
Link copied to clipboard
open class Time(val suffix: String, val ratio: Double = 1.0) : Units

Units to measure time durations.

Link copied to clipboard
abstract class Units(val suffix: String, val ratio: Double = 1.0)

Base class for all types that can represent a unit of measure. A Units type can have multiple "members", each being some fraction of the base unit for that type. Time for example, might have seconds as the base unit and minute as a unit that is 60 times the base unit. This allows for a set of different representations of the unit.

Link copied to clipboard
class UnitsProduct<A : Units, B : Units>(val first: A, val second: B) : Units

Represents the product of two Units: A * B.

Link copied to clipboard
class UnitsRatio<A : Units, B : Units>(val numerator: A, val denominator: B) : Units

Represents the ratio of two Units: A / B.

Link copied to clipboard

Inherited properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun <T : Units> abs(measure: Measure<T>): Measure<T>
Link copied to clipboard
fun <T : Units> ceil(measure: Measure<T>): Measure<T>

Rounds the measure to the next, larger integer, retaining its units.

Link copied to clipboard
fun <T : Units> floor(measure: Measure<T>): Measure<T>

Rounds the measure to the previous, smaller integer, retaining its units.

Link copied to clipboard
fun <A : Units, B : A> minOf(first: A, second: B): A
Link copied to clipboard
fun <T : Units> round(measure: Measure<T>): Measure<T>

Rounds the measure to the closest integer, retaining its units.

fun <T : Units> round(measure: Measure<T>, toNearest: Measure<T>): Measure<T>

Returns a Measure that is rounded to he closest multiple of toNearest, and has the the units of toNearest.

Inherited functions

Link copied to clipboard
operator fun <A : Units, B : A> A.compareTo(other: B): Int

Compares two units

Link copied to clipboard
operator fun <A : Units, B : Units> A.div(other: B): UnitsRatio<A, B>

A / B

operator fun <A : Units, B : Units> A.div(other: UnitsRatio<A, B>): Measure<B>

A / (A / B) == A * (B / A)

operator fun <A : Units> InverseUnits<A>.div(other: A): Measure<InverseUnits<Square<A>>>
@JvmName(name = "div16")
operator fun <A : Units> Measure<A>.div(other: A): Double
@JvmName(name = "div16")
operator fun <A : Units, B : Units> Measure<A>.div(other: B): Measure<UnitsRatio<A, B>>
@JvmName(name = "div16")
operator fun <A : Units> Measure<A>.div(other: Measure<A>): Double
@JvmName(name = "div16")
operator fun <A : Units, B : Units> Measure<A>.div(other: Measure<B>): Measure<UnitsRatio<A, B>>
@JvmName(name = "div15")
operator fun <A : Units, B : Units> Measure<A>.div(other: Measure<UnitsRatio<A, B>>): Measure<B>
@JvmName(name = "div15")
operator fun <A : Units, B : Units> Measure<A>.div(other: UnitsRatio<A, B>): Measure<B>
@JvmName(name = "div18")
operator fun <A : Units> Measure<InverseUnits<A>>.div(other: Measure<A>): Measure<InverseUnits<Square<A>>>
@JvmName(name = "div17")
operator fun <A : Units> Measure<InverseUnits<A>>.div(other: Measure<InverseUnits<Square<A>>>): Measure<A>
@JvmName(name = "div1")
operator fun <A : Units, B : Units> Measure<UnitsProduct<A, B>>.div(other: A): Measure<B>
@JvmName(name = "div2")
operator fun <A : Units, B : Units> Measure<UnitsProduct<A, B>>.div(other: B): Measure<A>
@JvmName(name = "div1")
operator fun <A : Units, B : Units> Measure<UnitsProduct<A, B>>.div(other: Measure<A>): Measure<B>
@JvmName(name = "div2")
operator fun <A : Units, B : Units> Measure<UnitsProduct<A, B>>.div(other: Measure<B>): Measure<A>
@JvmName(name = "div3")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsProduct<A, B>>.div(other: Measure<UnitsProduct<C, B>>): Measure<UnitsRatio<A, C>>
@JvmName(name = "div4")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsProduct<A, B>>.div(other: Measure<UnitsProduct<C, A>>): Measure<UnitsRatio<B, C>>
@JvmName(name = "div5")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsProduct<A, B>>.div(other: Measure<UnitsProduct<B, C>>): Measure<UnitsRatio<A, C>>
@JvmName(name = "div6")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsProduct<A, B>>.div(other: Measure<UnitsProduct<A, C>>): Measure<UnitsRatio<B, C>>
@JvmName(name = "div7")
operator fun <A : Units, B : Units> Measure<UnitsProduct<A, B>>.div(other: Measure<UnitsProduct<A, A>>): Measure<UnitsRatio<B, A>>
@JvmName(name = "div8")
operator fun <A : Units, B : Units> Measure<UnitsProduct<A, B>>.div(other: Measure<UnitsProduct<B, B>>): Measure<UnitsRatio<A, B>>
@JvmName(name = "div3")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsProduct<A, B>>.div(other: UnitsProduct<C, B>): Measure<UnitsRatio<A, C>>
@JvmName(name = "div4")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsProduct<A, B>>.div(other: UnitsProduct<C, A>): Measure<UnitsRatio<B, C>>
@JvmName(name = "div5")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsProduct<A, B>>.div(other: UnitsProduct<B, C>): Measure<UnitsRatio<A, C>>
@JvmName(name = "div6")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsProduct<A, B>>.div(other: UnitsProduct<A, C>): Measure<UnitsRatio<B, C>>
@JvmName(name = "div7")
operator fun <A : Units, B : Units> Measure<UnitsProduct<A, B>>.div(other: UnitsProduct<A, A>): Measure<UnitsRatio<B, A>>
@JvmName(name = "div8")
operator fun <A : Units, B : Units> Measure<UnitsProduct<A, B>>.div(other: UnitsProduct<B, B>): Measure<UnitsRatio<A, B>>
@JvmName(name = "div9")
operator fun <A : Units, B : Units> Measure<UnitsRatio<A, B>>.div(other: B): Measure<UnitsRatio<A, UnitsProduct<B, B>>>
@JvmName(name = "div19")
operator fun <A : Units, B : Units> Measure<UnitsRatio<A, B>>.div(other: Measure<B>): Measure<UnitsRatio<A, UnitsProduct<B, B>>>
@JvmName(name = "div9")
operator fun <A : Units, B : Units> Measure<UnitsRatio<A, B>>.div(other: Measure<A>): Measure<InverseUnits<B>>
@JvmName(name = "div10")
operator fun <A : Units, B : Units, C : Units, D : Units> Measure<UnitsRatio<A, B>>.div(other: Measure<UnitsRatio<C, D>>): Measure<UnitsRatio<UnitsProduct<A, D>, UnitsProduct<B, C>>>
@JvmName(name = "div11")
operator fun <A : Units, B : Units> Measure<UnitsRatio<A, B>>.div(other: Measure<UnitsRatio<A, Square<B>>>): Measure<B>
@JvmName(name = "div10")
operator fun <A : Units, B : Units, C : Units, D : Units> Measure<UnitsRatio<A, B>>.div(other: UnitsRatio<C, D>): Measure<UnitsRatio<UnitsProduct<A, D>, UnitsProduct<B, C>>>
@JvmName(name = "div11")
operator fun <A : Units, B : Units> Measure<UnitsRatio<A, B>>.div(other: UnitsRatio<A, Square<B>>): Measure<B>
@JvmName(name = "div12")
operator fun <A : Units, B : Units> Measure<UnitsRatio<UnitsProduct<A, A>, UnitsProduct<B, B>>>.div(other: A): Measure<UnitsRatio<A, UnitsProduct<B, B>>>
@JvmName(name = "div13")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsRatio<UnitsProduct<A, A>, UnitsProduct<B, C>>>.div(other: A): Measure<UnitsRatio<A, UnitsProduct<B, C>>>
@JvmName(name = "div14")
operator fun <A : Units, B : Units, C : Units, D : Units> Measure<UnitsRatio<UnitsProduct<A, B>, UnitsProduct<C, D>>>.div(other: A): Measure<UnitsRatio<B, UnitsProduct<C, D>>>
@JvmName(name = "div12")
operator fun <A : Units, B : Units> Measure<UnitsRatio<UnitsProduct<A, A>, UnitsProduct<B, B>>>.div(other: Measure<A>): Measure<UnitsRatio<A, UnitsProduct<B, B>>>
@JvmName(name = "div13")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsRatio<UnitsProduct<A, A>, UnitsProduct<B, C>>>.div(other: Measure<A>): Measure<UnitsRatio<A, UnitsProduct<B, C>>>
@JvmName(name = "div14")
operator fun <A : Units, B : Units, C : Units, D : Units> Measure<UnitsRatio<UnitsProduct<A, B>, UnitsProduct<C, D>>>.div(other: Measure<A>): Measure<UnitsRatio<B, UnitsProduct<C, D>>>
operator fun <A : Units, B : Units> UnitsRatio<A, B>.div(other: B): UnitsRatio<A, UnitsProduct<B, B>>
operator fun <A : Units, B : Units> UnitsRatio<A, B>.div(other: A): Measure<InverseUnits<B>>
@JvmName(name = "div1")
operator fun <A : Units, B : Units> UnitsRatio<A, B>.div(other: UnitsRatio<A, B>): Double
@JvmName(name = "div2")
operator fun <A : Units, B : Units> UnitsRatio<A, B>.div(other: UnitsRatio<B, A>): UnitsRatio<UnitsProduct<A, A>, UnitsProduct<B, B>>
@JvmName(name = "div3")
operator fun <A : Units, B : Units, C : Units, D : Units> UnitsRatio<A, B>.div(other: UnitsRatio<C, D>): UnitsRatio<UnitsProduct<A, D>, UnitsProduct<B, C>>
operator fun <A : Units, B : Units> UnitsRatio<A, B>.div(other: UnitsRatio<A, Square<B>>): Measure<B>
@JvmName(name = "div1")
operator fun <A : Units, B : Units> UnitsRatio<UnitsProduct<A, A>, UnitsProduct<B, B>>.div(other: A): Measure<UnitsRatio<A, UnitsProduct<B, B>>>
@JvmName(name = "div2")
operator fun <A : Units, B : Units, C : Units> UnitsRatio<UnitsProduct<A, A>, UnitsProduct<B, C>>.div(other: A): Measure<UnitsRatio<A, UnitsProduct<B, C>>>
@JvmName(name = "div3")
operator fun <A : Units, B : Units, C : Units, D : Units> UnitsRatio<UnitsProduct<A, B>, UnitsProduct<C, D>>.div(other: A): Measure<UnitsRatio<B, UnitsProduct<C, D>>>
operator fun <T : Units> Number.div(unit: T): Measure<InverseUnits<T>>
@JvmName(name = "divMeasure")
operator fun <T : Units> Number.div(measure: Measure<T>): Measure<InverseUnits<T>>
@JvmName(name = "divInvMeasure")
operator fun <T : Units> Number.div(measure: Measure<InverseUnits<T>>): Measure<T>

@JvmName(name = "div1")
operator fun <A : Units, B : Units> UnitsProduct<A, B>.div(other: A): Measure<B>

(A * B) / A

@JvmName(name = "div2")
operator fun <A : Units, B : Units> UnitsProduct<A, B>.div(other: B): Measure<A>

(A * B) / B

@JvmName(name = "div3")
operator fun <A : Units> UnitsProduct<A, A>.div(other: A): Measure<A>

(A * A) / A

@JvmName(name = "div1")
operator fun <A : Units, B : Units, C : Units> UnitsProduct<A, B>.div(other: UnitsProduct<C, B>): UnitsRatio<A, C>

(A * B) / (C * B)

@JvmName(name = "div2")
operator fun <A : Units, B : Units, C : Units> UnitsProduct<A, B>.div(other: UnitsProduct<C, A>): UnitsRatio<B, C>

(A * B) / (C * A)

@JvmName(name = "div3")
operator fun <A : Units, B : Units, C : Units> UnitsProduct<A, B>.div(other: UnitsProduct<B, C>): UnitsRatio<A, C>

(A * B) / (B * C)

@JvmName(name = "div4")
operator fun <A : Units, B : Units, C : Units> UnitsProduct<A, B>.div(other: UnitsProduct<A, C>): UnitsRatio<B, C>

(A * B) / (A * C)

@JvmName(name = "div5")
operator fun <A : Units, B : Units> UnitsProduct<A, B>.div(other: UnitsProduct<A, A>): UnitsRatio<B, A>

(A * B) / (A * A)

@JvmName(name = "div7")
operator fun <A : Units, B : Units> UnitsProduct<A, B>.div(other: UnitsProduct<A, B>): Double

(A * B) / (A * B)

@JvmName(name = "div6")
operator fun <A : Units, B : Units> UnitsProduct<A, B>.div(other: UnitsProduct<B, A>): Double

(A * B) / (B * A)

@JvmName(name = "div8")
operator fun <A : Units, B : Units> UnitsProduct<A, B>.div(other: UnitsProduct<B, B>): Measure<UnitsRatio<A, B>>

(A * B) / (B * B)

Link copied to clipboard
operator fun <T : Units> T.invoke(value: Number): Measure<T>
Link copied to clipboard

Returns a measure that is within [0°, 360°)

Link copied to clipboard
operator fun <A : Units> Measure<A>.rem(other: Measure<A>): Double
operator fun <A : Units> Measure<A>.rem(other: Double): Measure<A>
Link copied to clipboard
operator fun <A : Units, B : Units> A.times(other: B): UnitsProduct<A, B>

A * B

@JvmName(name = "times7")
operator fun <A : Units> A.times(other: InverseUnits<A>): Double
operator fun <T : Units> T.times(value: Number): Measure<T>
@JvmName(name = "times8")
operator fun <A : Units> InverseUnits<A>.times(other: A): Double
@JvmName(name = "times9")
operator fun <A : Units, B : Units> InverseUnits<A>.times(other: B): UnitsRatio<B, A>
operator fun Length.times(mass: Mass): UnitsProduct<Mass, Length>
@JvmName(name = "times1")
operator fun <A : Units, B : Units> Measure<A>.times(other: B): Measure<UnitsProduct<A, B>>
@JvmName(name = "times16")
operator fun <A : Units> Measure<A>.times(other: InverseUnits<A>): Double
@JvmName(name = "times7")
operator fun <A : Units, B : Units> Measure<A>.times(other: InverseUnits<B>): Measure<UnitsRatio<A, B>>
@JvmName(name = "times1")
operator fun <A : Units, B : Units> Measure<A>.times(other: Measure<B>): Measure<UnitsProduct<A, B>>
@JvmName(name = "times7")
operator fun <A : Units, B : Units> Measure<A>.times(other: Measure<InverseUnits<B>>): Measure<UnitsRatio<A, B>>
@JvmName(name = "times11")
operator fun <A : Units> Measure<A>.times(other: Measure<InverseUnits<A>>): Double
@JvmName(name = "times8")
operator fun <A : Units> Measure<A>.times(other: Measure<InverseUnits<Square<A>>>): Measure<InverseUnits<A>>
@JvmName(name = "times2")
operator fun <A : Units, B : Units> Measure<A>.times(other: Measure<UnitsRatio<B, A>>): Measure<B>
@JvmName(name = "times2")
operator fun <A : Units, B : Units> Measure<A>.times(other: UnitsRatio<B, A>): Measure<B>
@JvmName(name = "times16")
operator fun <A : Units> Measure<InverseUnits<A>>.times(other: A): Double
@JvmName(name = "times16")
operator fun <A : Units, B : Units> Measure<InverseUnits<A>>.times(other: B): Measure<UnitsRatio<B, A>>
@JvmName(name = "times10")
operator fun <A : Units> Measure<InverseUnits<A>>.times(other: Measure<A>): Double
@JvmName(name = "times10")
operator fun <A : Units> Measure<InverseUnits<A>>.times(other: Measure<InverseUnits<A>>): Measure<InverseUnits<Square<A>>>
@JvmName(name = "times9")
operator fun <A : Units> Measure<InverseUnits<Square<A>>>.times(other: Measure<A>): Measure<InverseUnits<A>>
@JvmName(name = "times3")
operator fun <A : Units, B : Units> Measure<UnitsRatio<A, B>>.times(other: B): Measure<A>
@JvmName(name = "times3")
operator fun <A : Units, B : Units> Measure<UnitsRatio<A, B>>.times(other: Measure<B>): Measure<A>
@JvmName(name = "times4")
operator fun <A : Units, B : Units> Measure<UnitsRatio<A, B>>.times(other: Measure<UnitsRatio<A, B>>): Measure<UnitsRatio<UnitsProduct<A, A>, UnitsProduct<B, B>>>
@JvmName(name = "times4")
operator fun <A : Units, B : Units> Measure<UnitsRatio<A, B>>.times(other: UnitsRatio<A, B>): Measure<UnitsRatio<UnitsProduct<A, A>, UnitsProduct<B, B>>>
@JvmName(name = "times5")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsRatio<A, UnitsProduct<B, C>>>.times(other: B): Measure<UnitsRatio<A, C>>
@JvmName(name = "times6")
operator fun <A : Units, B : Units, C : Units, D : Units> Measure<UnitsRatio<A, UnitsProduct<B, C>>>.times(other: D): Measure<UnitsRatio<UnitsProduct<A, D>, UnitsProduct<B, C>>>
@JvmName(name = "times5")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsRatio<A, UnitsProduct<B, C>>>.times(other: Measure<B>): Measure<UnitsRatio<A, C>>
@JvmName(name = "times6")
operator fun <A : Units, B : Units, C : Units, D : Units> Measure<UnitsRatio<A, UnitsProduct<B, C>>>.times(other: Measure<D>): Measure<UnitsRatio<UnitsProduct<A, D>, UnitsProduct<B, C>>>
operator fun <T : Units> Number.times(unit: T): Measure<T>
operator fun <T : Units> Number.times(measure: Measure<T>): Measure<T>

operator fun <A : Units, B : Units> A.times(other: InverseUnits<B>): UnitsRatio<A, B>

A * (1 / B)

operator fun <A : Units> A.times(other: InverseUnits<Square<A>>): Measure<InverseUnits<A>>

A * (1 / A^2)

operator fun <A : Units, B : Units> A.times(other: UnitsRatio<B, A>): Measure<B>

A * (B / A)

operator fun Time.times(other: Length): UnitsProduct<Length, Time>

Sort Length before Time which is conventional.

@JvmName(name = "times1")
operator fun <A : Units, B : Units> UnitsRatio<A, B>.times(other: B): Measure<A>

(A / B) * B

@JvmName(name = "times4")
operator fun <A : Units, B : Units> UnitsRatio<A, B>.times(other: UnitsRatio<A, B>): UnitsRatio<UnitsProduct<A, A>, UnitsProduct<B, B>>

(A / B) * (A / B)

@JvmName(name = "times5")
operator fun <A : Units, B : Units> UnitsRatio<A, B>.times(other: UnitsRatio<B, A>): Double

(A / B) * (B / A))

@JvmName(name = "times6")
operator fun <A : Units, B : Units, C : Units, D : Units> UnitsRatio<A, B>.times(other: UnitsRatio<C, D>): UnitsRatio<UnitsProduct<A, C>, UnitsProduct<B, D>>

(A / B) * (C / D))

@JvmName(name = "times2")
operator fun <A : Units, B : Units, C : Units> UnitsRatio<A, UnitsProduct<B, C>>.times(other: B): Measure<UnitsRatio<A, C>>

(A / (B * C)) * B

@JvmName(name = "times3")
operator fun <A : Units, B : Units, C : Units, D : Units> UnitsRatio<A, UnitsProduct<B, C>>.times(other: D): UnitsRatio<UnitsProduct<A, D>, UnitsProduct<B, C>>

(A / (B * C)) * D)

Link copied to clipboard
infix fun <T : Units> Measure<T>.toNearest(value: Measure<T>): Measure<T>

Returns a Measure that is rounded to he closest multiple of toNearest, and has the the units of toNearest.