All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.nacular.measured.units.Length.kt Maven / Gradle / Ivy

There is a newer version: 0.4.1
Show newest version
package io.nacular.measured.units

/**
 * Units for length or distance.
 */
open class Length(suffix: String, ratio: Double = 1.0): Units(suffix, ratio) {
    operator fun div(other: Length) = ratio / other.ratio

    companion object {
        val miles       = Length("mi", 1609.3440)
        val millimeters = Length("mm",    0.0010)
        val centimeters = Length("cm",    0.0100)
        val meters      = Length("m"            )
        val inches      = Length("in",    0.0254)
        val feet        = Length("ft", 12 * inches `in` meters)
        val kilometers  = Length("km", 1000.0000)
    }
}

/**
 * Sort Length before Time which is conventional.
 */
operator fun Time.times(other: Length) = other * this
operator fun Measure




© 2015 - 2024 Weber Informatics LLC | Privacy Policy