Measure

class Measure<T : Units>(val amount: Double, val units: T) : Comparable<Measure<T>> (source)

A quantity with a unit type.

Constructors

Link copied to clipboard
constructor(amount: Double, units: T)

Properties

Link copied to clipboard

of the measure (i.e. it's coefficient)

Link copied to clipboard
val units: T

of the measure

Inherited properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
infix fun <A : T> as(other: A): Measure<T>

Convert this Measure into another compatible one with different units. Type must share parent (i.e. Mile into Kilometer, because they both are made from Distance)

Link copied to clipboard
open operator override fun compareTo(other: Measure<T>): Int

Compare this value with another quantity - which must have the same type Units are converted before comparison

Link copied to clipboard
operator fun div(other: Number): Measure<T>

Divide this by a scalar, used for things like "halve the speed"

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
infix fun <A : T> in(other: A): Double

Gets the value of the Measure in the given unit.

Link copied to clipboard
operator fun minus(other: Measure<T>): Measure<T>

Subtract a compatible quantity from this one

Link copied to clipboard
operator fun plus(other: Measure<T>): Measure<T>

Add another compatible quantity to this one

Link copied to clipboard

Rounds this Measure to the closest integer value.

Link copied to clipboard
operator fun times(other: Number): Measure<T>

Multiply this by a scalar value, used for things like "double this distance", "1.5 times the speed", etc

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
operator fun unaryMinus(): Measure<T>

Inherited functions

Link copied to clipboard
@JvmName(name = "div16")
operator fun <A : Units> Measure<A>.div(other: A): Double
@JvmName(name = "div16")
operator fun <A : Units> Measure<A>.div(other: Measure<A>): Double
@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 = "div1")
operator fun <A : Units, B : Units> Measure<UnitsProduct<A, B>>.div(other: Measure<A>): Measure<B>
@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 = "div3")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsProduct<A, B>>.div(other: UnitsProduct<C, B>): Measure<UnitsRatio<A, C>>
@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 = "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 = "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>>>
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
@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 = "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 = "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 = "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 = "times5")
operator fun <A : Units, B : Units, C : Units> Measure<UnitsRatio<A, UnitsProduct<B, C>>>.times(other: Measure<B>): Measure<UnitsRatio<A, C>>
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.