Class Unit

java.lang.Object
me.autobot.lib.math.Unit

public class Unit extends Object
A class to represent a unit of measurement. Can be used for conversion, tracking, etc.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The type of unit.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Unit(double inMeters)
    Creates a unit with the value in meters.
    Unit(double value, Unit.Type type)
    Creates a unit with the value in the given unit.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the value in meters.
    double
    Gets the value in the given unit.
    static Unit
    The zero unit.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Unit

      public Unit(double inMeters)
      Creates a unit with the value in meters.
      Parameters:
      inMeters - The value in meters
    • Unit

      public Unit(double value, Unit.Type type)
      Creates a unit with the value in the given unit.
      Parameters:
      value - The value in the given unit
      type - The unit of the value
  • Method Details

    • zero

      public static Unit zero()
      The zero unit. Equivalent to 0 meters, or 0 of any other unit.
      Returns:
      The zero unit
    • getValue

      public double getValue(Unit.Type type)
      Gets the value in the given unit.
      Parameters:
      type - The unit to convert to
      Returns:
      The value in the given unit
    • getValue

      public double getValue()
      Returns the value in meters.
      Returns:
      The value in meters