|
RobotCore 1.0
WPILib port to raspberry Pi
|
Public Member Functions | |
| abstract Measure<?> | of (double magnitude) |
| abstract Measure<?> | ofBaseUnits (double baseUnitMagnitude) |
| Measure<?> | zero () |
| Measure<?> | one () |
| abstract Unit | per (TimeUnit time) |
| Unit | getBaseUnit () |
| boolean | isBaseUnit () |
| double | fromBaseUnits (double valueInBaseUnits) |
| double | toBaseUnits (double valueInNativeUnits) |
| UnaryFunction | getConverterToBase () |
| UnaryFunction | getConverterFromBase () |
| boolean | equivalent (Unit other) |
| boolean | equals (Object o) |
| int | hashCode () |
| String | name () |
| String | symbol () |
| String | toString () |
Protected Member Functions | |
| Unit (Unit baseUnit, UnaryFunction toBaseConverter, UnaryFunction fromBaseConverter, String name, String symbol) | |
| Unit (Unit baseUnit, double baseUnitEquivalent, String name, String symbol) | |
Unit of measurement that defines a quantity, such as grams, meters, or seconds.
This is the base class for units. Actual units (such as Units#Grams and Units#Meters) can be found in the Units class.
|
protected |
Creates a new unit defined by its relationship to some base unit.
| baseUnit | the base unit, e.g. Meters for distances. Set this to null if the unit being constructed is its own base unit |
| toBaseConverter | a function for converting units of this type to the base unit |
| fromBaseConverter | a function for converting units of the base unit to this one |
| name | the name of the unit. This should be a singular noun (so "Meter", not "Meters") |
| symbol | the short symbol for the unit, such as "m" for meters or "lb." for pounds |
|
protected |
Creates a new unit with the given name and multiplier to the base unit.
| baseUnit | the base unit, e.g. Meters for distances |
| baseUnitEquivalent | the multiplier to convert this unit to the base unit of this type. For example, meters has a multiplier of 1, mm has a multiplier of 1e3, and km has multiplier of 1e-3. |
| name | the name of the unit. This should be a singular noun (so "Meter", not "Meters") |
| symbol | the short symbol for the unit, such as "m" for meters or "lb." for pounds |
| boolean org.wpilib.units.Unit.equivalent | ( | Unit | other | ) |
Checks if this unit is equivalent to another one. Equivalence is determined by both units having the same base type and treat the same base unit magnitude as the same magnitude in their own units, to within Measure#EQUIVALENCE_THRESHOLD.
| other | the unit to compare to. |
| double org.wpilib.units.Unit.fromBaseUnits | ( | double | valueInBaseUnits | ) |
| Unit org.wpilib.units.Unit.getBaseUnit | ( | ) |
Gets 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
Reimplemented in org.wpilib.units.AngleUnit, org.wpilib.units.CurrentUnit, org.wpilib.units.DimensionlessUnit, org.wpilib.units.DistanceUnit, org.wpilib.units.EnergyUnit, org.wpilib.units.MassUnit, org.wpilib.units.MultUnit< A extends Unit, B extends Unit >, org.wpilib.units.PerUnit< N extends Unit, D extends Unit >, org.wpilib.units.TemperatureUnit, org.wpilib.units.TimeUnit, and org.wpilib.units.VoltageUnit.
| UnaryFunction org.wpilib.units.Unit.getConverterFromBase | ( | ) |
Gets the conversion function used to convert values to terms of this unit. This generally shouldn't need to be used directly; prefer fromBaseUnits(double) instead.
| UnaryFunction org.wpilib.units.Unit.getConverterToBase | ( | ) |
Gets the conversion function used to convert values to base unit terms. This generally shouldn't need to be used directly; prefer toBaseUnits(double) instead.
| boolean org.wpilib.units.Unit.isBaseUnit | ( | ) |
| String org.wpilib.units.Unit.name | ( | ) |
|
abstract |
Creates 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.
| magnitude | the magnitude of the measurement. |
Reimplemented in org.wpilib.units.AngleUnit, org.wpilib.units.CurrentUnit, org.wpilib.units.DimensionlessUnit, org.wpilib.units.DistanceUnit, org.wpilib.units.EnergyUnit, org.wpilib.units.MassUnit, org.wpilib.units.MultUnit< A extends Unit, B extends Unit >, org.wpilib.units.PerUnit< N extends Unit, D extends Unit >, org.wpilib.units.TemperatureUnit, org.wpilib.units.TimeUnit, and org.wpilib.units.VoltageUnit.
|
abstract |
Creates 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.
| baseUnitMagnitude | the magnitude in terms of the base unit |
Reimplemented in org.wpilib.units.AngleUnit, org.wpilib.units.CurrentUnit, org.wpilib.units.DimensionlessUnit, org.wpilib.units.DistanceUnit, org.wpilib.units.EnergyUnit, org.wpilib.units.MassUnit, org.wpilib.units.MultUnit< A extends Unit, B extends Unit >, org.wpilib.units.PerUnit< N extends Unit, D extends Unit >, org.wpilib.units.TemperatureUnit, org.wpilib.units.TimeUnit, and org.wpilib.units.VoltageUnit.
| Measure<?> org.wpilib.units.Unit.one | ( | ) |
Gets 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 by of(double). Subclasses are encouraged to override this method to sharpen the return type.
Reimplemented in org.wpilib.units.AngleUnit, org.wpilib.units.CurrentUnit, org.wpilib.units.DimensionlessUnit, org.wpilib.units.DistanceUnit, org.wpilib.units.EnergyUnit, org.wpilib.units.MassUnit, org.wpilib.units.MultUnit< A extends Unit, B extends Unit >, org.wpilib.units.PerUnit< N extends Unit, D extends Unit >, org.wpilib.units.TemperatureUnit, org.wpilib.units.TimeUnit, and org.wpilib.units.VoltageUnit.
Combines this unit with a unit of time. This often - but not always - results in a velocity. Subclasses should sharpen the return type to be unit-specific.
| time | the unit of time |
Reimplemented in org.wpilib.units.AngleUnit, org.wpilib.units.CurrentUnit, org.wpilib.units.DimensionlessUnit, org.wpilib.units.DistanceUnit, org.wpilib.units.EnergyUnit, org.wpilib.units.MassUnit, org.wpilib.units.MultUnit< A extends Unit, B extends Unit >, org.wpilib.units.PerUnit< N extends Unit, D extends Unit >, org.wpilib.units.TemperatureUnit, org.wpilib.units.TimeUnit, and org.wpilib.units.VoltageUnit.
| String org.wpilib.units.Unit.symbol | ( | ) |
| double org.wpilib.units.Unit.toBaseUnits | ( | double | valueInNativeUnits | ) |
| Measure<?> org.wpilib.units.Unit.zero | ( | ) |
Gets a measure of zero magnitude in terms of this unit. The returned object is guaranteed to be of the same type returned by of(double). Subclasses are encouraged to override this method to sharpen the return type.
Reimplemented in org.wpilib.units.AngleUnit, org.wpilib.units.CurrentUnit, org.wpilib.units.DimensionlessUnit, org.wpilib.units.DistanceUnit, org.wpilib.units.EnergyUnit, org.wpilib.units.MassUnit, org.wpilib.units.MultUnit< A extends Unit, B extends Unit >, org.wpilib.units.PerUnit< N extends Unit, D extends Unit >, org.wpilib.units.TemperatureUnit, org.wpilib.units.TimeUnit, and org.wpilib.units.VoltageUnit.