Skip to main content

DistanceUnit

An enum representing a range of distance units, including:

  • CENTIMETERS
  • INCHES
  • METERS
  • FEET
  • YARDS
  • MILES
  • KILOMETERS
  • NAUTICAL_MILES
  • LIGHT_YEARS
  • PARSECS
  • ANGSTROMS
  • FURLONGS
  • FERMATS
  • SMOOTS
  • AUS
  • FATHOMS
  • HANDS
  • LINKS
  • PACES
  • RODS
  • SPANS
  • LEAGUES

Utility Methods

distanceUnit.toIn

Converts the given distance to inches using the given distance unit.

Params
  • x: Number - The distance to convert to inches
  • DistanceUnit.CM.toIn(1.0); // 0.3937007874015748

    DistanceUnit.SMOOT.toIn(1.0); // 5.02921005842012

    DistanceUnit.PARSEC.toIn(1.0); // 1.215094e+19

    distanceUnit.toCm

    Converts the given distance to centimeters using the given distance unit.

    Params
  • x: Number - The distance to convert to centimeters
  • DistanceUnit.INCHES.toCm(1.0); // 2.54

    DistanceUnit.SMOOT.toCm(1.0); // 152.4

    DistanceUnit.PARSEC.toCm(1.0); // 3.08567758e+18

    distanceUnit.to

    Converts the given distance to the given distance unit.

    Params
  • to: DistanceUnit - The distance unit to convert to
  • x: Number - The distance to convert
  • DistanceUnit.INCHES.to(DistanceUnit.CM, 1.0); // 2.54

    DistanceUnit.SMOOT.to(DistanceUnit.CM, 1.0); // 152.4

    DistanceUnit.PARSEC.to(DistanceUnit.CM, 1.0); // 3.08567758e+18