Class Per<N extends Unit<N>,​D extends Unit<D>>

java.lang.Object
edu.wpi.first.units.Unit<Per<N,​D>>
edu.wpi.first.units.Per<N,​D>
Type Parameters:
N - the type of the numerator unit
D - the type of the denominator unit

public class Per<N extends Unit<N>,​D extends Unit<D>>
extends Unit<Per<N,​D>>
Generic combinatory unit type that represents the proportion of one unit to another, such as Meters per Second or Radians per Celsius.

Note: Velocity is used to represent the velocity dimension, rather than Per<Distance, Time>.

  • Constructor Details

    • Per

      protected Per​(Class<Per<N,​D>> baseType, N numerator, D denominator)
      Creates a new proportional unit derived from the ratio of one unit to another. Consider using combine(N, D) instead of manually calling this constructor.
      Parameters:
      baseType - the base type representing the unit ratio
      numerator - the numerator unit
      denominator - the denominator unit
  • Method Details

    • combine

      public static <N extends Unit<N>,​ D extends Unit<D>> Per<N,​D> combine​(N numerator, D denominator)
      Creates a new Per unit derived from an arbitrary numerator and time denominator units. Using a denominator with a unit of time is discouraged; use Velocity instead.
         Per.combine(Volts, Meters) // possible PID constant
       

      It's recommended to use the convenience function Unit.per(Unit) instead of calling this factory directly.

      Type Parameters:
      N - the type of the numerator unit
      D - the type of the denominator unit
      Parameters:
      numerator - the numerator unit
      denominator - the denominator for unit time
      Returns:
      the combined unit
    • numerator

      public N numerator()
      Gets the numerator unit. For a Per<A, B>, this will return the A unit.
      Returns:
      the numerator unit
    • denominator

      public D denominator()
      Gets the denominator unit. For a Per<A, B>, this will return the B unit.
      Returns:
      the denominator unit
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Unit<Per<N extends Unit<N>,​D extends Unit<D>>>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Unit<Per<N extends Unit<N>,​D extends Unit<D>>>