Length

Represents a length or distance, internally stored as a Double of meters.

Most arithmetic operations are supported, and will automatically result in a scalar, Length, or Area depending on the operation.

See also

Types

Link copied to clipboard
object Companion

Companion object containing predefined length values.

Properties

Link copied to clipboard

Returns the absolute value of this length.

Link copied to clipboard

Returns this Length as a scalar value in cables.

Link copied to clipboard

Returns this Length as a scalar value in centimeters.

Link copied to clipboard

Returns this Length as a scalar value in chains.

Link copied to clipboard

Returns this Length as a scalar value in earth degrees.

Link copied to clipboard

Returns this Length as a scalar value in earth minutes.

Link copied to clipboard

Returns this Length as a scalar value in earth radians.

Link copied to clipboard

Returns this Length as a scalar value in earth seconds.

Link copied to clipboard

Returns this Length as a scalar value in fathoms.

Link copied to clipboard

Returns this Length as a scalar value in feet.

Link copied to clipboard

Returns this Length as a scalar value in furlongs.

Link copied to clipboard

Returns this Length as a scalar value in inches.

Link copied to clipboard

Returns this Length as a scalar value in kilometers.

Link copied to clipboard

Returns this Length as a scalar value in leagues.

Link copied to clipboard

Returns this Length as a scalar value in links.

Link copied to clipboard

Returns this Length as a scalar value in meters.

Link copied to clipboard

Returns this Length as a scalar value in miles.

Link copied to clipboard

Returns this Length as a scalar value in millimeters.

Link copied to clipboard

Returns this Length as a scalar value in nautical miles.

Link copied to clipboard

Returns this Length as a scalar value in rods.

Link copied to clipboard

Returns this Length as a scalar value in yards.

Link copied to clipboard

Returns true if this length is finite (not infinite).

Link copied to clipboard

Returns true if this length is infinite (positive or negative).

Link copied to clipboard

Returns true if this length is less than zero.

Link copied to clipboard

Returns true if this length is greater than zero.

Link copied to clipboard

Returns true if this length is equal to zero.

Functions

Link copied to clipboard
open operator override fun compareTo(other: Length): Int
Link copied to clipboard
operator fun div(other: Double): Length

Divides this length by a scalar value.

operator fun div(other: Length): Double

Divides this length by another length, resulting in a dimensionless scalar.

Link copied to clipboard
operator fun minus(other: Length): Length

Subtracts another length from this length.

Link copied to clipboard
fun mod(other: Length): Length

Returns the modulo of this length with respect to another length.

Link copied to clipboard
operator fun plus(other: Length): Length

Adds another length to this length.

Link copied to clipboard
operator fun rem(other: Length): Length

Returns the remainder of dividing this length by another length.

Link copied to clipboard

Rounds this length to an Int value in the specified unit.

Link copied to clipboard

Rounds this length to a Long value in the specified unit.

Link copied to clipboard
operator fun times(other: Double): Length

Multiplies this length by a scalar value.

operator fun times(other: Length): Area

Multiplies this Length by another Length, resulting in an Area.

Link copied to clipboard

Converts this length to a Double value in the specified unit.

Link copied to clipboard

Converts this length to a Float value in the specified unit.

Link copied to clipboard
open override fun toString(): String

Returns a string representation of this length in meters.

fun toString(unit: LengthUnit = Meters, decimalPlaces: Int = 2): String

Returns a formatted string representation of this length.

Link copied to clipboard
operator fun unaryMinus(): Length

Returns the negation of this length.

Link copied to clipboard
operator fun unaryPlus(): Length

Returns this length unchanged.