Package edu.wpi.first.units
Class DimensionlessUnit
java.lang.Object
edu.wpi.first.units.Unit
edu.wpi.first.units.DimensionlessUnit
A type of unit that corresponds to raw values and not any physical dimension, such as percentage.
-
Method Summary
Modifier and TypeMethodDescriptiondoubleconvertFrom(double magnitude, DimensionlessUnit otherUnit) Converts a measurement value in terms of another dimensionless unit to this unit.Gets the base unit of measurement that this unit is derived from.mutable(double initialMagnitude) Creates a new mutable measurement that is initialized to the given magnitude in terms of this unit.of(double magnitude) Creates a new immutable measurement of the given magnitude in terms of this unit.ofBaseUnits(double baseUnitMagnitude) Creates a new immutable measurement of the given magnitude in terms of this unit's base unit.one()Gets a measure with a magnitude of 1.0 in terms of this unit.Creates a frequency unit as the ratio of this dimensionless unit to the period of time in which a single cycle is made.<U extends Unit>
PerUnit<DimensionlessUnit,U> per(U other) Creates a ratio unit between this unit and an arbitrary other unit.zero()Gets a measure of zero magnitude in terms of this unit.Methods inherited from class edu.wpi.first.units.Unit
equals, equivalent, fromBaseUnits, getConverterFromBase, getConverterToBase, hashCode, isBaseUnit, name, symbol, toBaseUnits, toString
-
Method Details
-
getBaseUnit
Description copied from class:UnitGets the base unit of measurement that this unit is derived from. If the unit is the base unit, the unit will be returned.NOTE: Subclasses must override this method to provide the correct return type. Failing to do say will make unit combinations that use it break at runtime!
Unit baseUnit = new Unit(null, ...); baseUnit.getBaseUnit(); // returns baseUnit Unit derivedUnit = new Unit(baseUnit, ...); derivedUnit.getBaseUnit(); // returns baseUnit- Overrides:
getBaseUnitin classUnit- Returns:
- the base unit
-
of
Description copied from class:UnitCreates a new immutable measurement of the given magnitude in terms of this unit. Implementations are strongly recommended to sharpen the return type to a unit-specific measurement implementation. -
ofBaseUnits
Description copied from class:UnitCreates a new immutable measurement of the given magnitude in terms of this unit's base unit. Implementations are strongly recommended to sharpen the return type to a unit-specific measurement implementation.- Specified by:
ofBaseUnitsin classUnit- Parameters:
baseUnitMagnitude- the magnitude in terms of the base unit- Returns:
- the measurement object
-
zero
Description copied from class:UnitGets a measure of zero magnitude in terms of this unit. The returned object is guaranteed to be of the same type returned byUnit.of(double). Subclasses are encouraged to override this method to sharpen the return type. -
one
Description copied from class:UnitGets a measure with a magnitude of 1.0 in terms of this unit. The returned object is guaranteed to be of the same type returned byUnit.of(double). Subclasses are encouraged to override this method to sharpen the return type. -
mutable
Description copied from class:UnitCreates a new mutable measurement that is initialized to the given magnitude in terms of this unit. Implementations are strongly recommended to sharpen the return type to a unit-specific measurement implementation. -
convertFrom
Converts a measurement value in terms of another dimensionless unit to this unit.- Parameters:
magnitude- the magnitude of the measurement in terms of the other dimensionless unitotherUnit- the other dimensionless unit- Returns:
- the value of the measurement in terms of this unit
-
per
Creates a frequency unit as the ratio of this dimensionless unit to the period of time in which a single cycle is made. -
per
Creates a ratio unit between this unit and an arbitrary other unit.- Type Parameters:
U- the type of the other unit- Parameters:
other- the other unit- Returns:
- the ratio unit
-