Class VelocityUnit<D extends Unit>
- Type Parameters:
D
- the unit of the changing quantity, such asVoltageUnit
orTemperatureUnit
This is a generic velocity type for units that do not have discrete velocity units (eg DistanceUnit
has LinearVelocityUnit
, and so would not use this class).
-
Method Summary
Modifier and TypeMethodDescriptionstatic <D extends Unit>
VelocityUnit<D>Combines a dimension unit and a unit of the period of change to create a unit of velocity.double
convertFrom
(double magnitude, VelocityUnit<? extends D> otherUnit) Converts a measurement value in terms of another velocity unit to this unit.Gets the base unit of measurement that this unit is derived from.Gets the period unit of the velocity, eg Seconds or Milliseconds.getUnit()
Gets the major unit being measured (eg Meters for Meters per Second).MutableMeasure<VelocityUnit<D>,
?, ?> 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.Measure<? extends VelocityUnit<D>>
one()
Gets a measure with a magnitude of 1.0 in terms of this unit.Combines this velocity unit with a unit of a period of change to create an acceleration unit.<U extends Unit>
PerUnit<VelocityUnit<D>,U> per
(U other) Creates a ratio unit between this unit and an arbitrary other unit.Measure<? extends VelocityUnit<D>>
zero()
Gets a measure of zero magnitude in terms of this unit.Methods inherited from class edu.wpi.first.units.PerUnit
combine, convertFrom, denominator, equals, hashCode, mult, mutableNative, numerator, ofNative, ofNativeBaseUnits, reciprocal
Methods inherited from class edu.wpi.first.units.Unit
equivalent, fromBaseUnits, getConverterFromBase, getConverterToBase, isBaseUnit, name, symbol, toBaseUnits, toString
-
Method Details
-
combine
Combines a dimension unit and a unit of the period of change to create a unit of velocity.- Type Parameters:
D
- the unit of the changing dimension- Parameters:
unit
- the unit of the changing dimensionperiod
- the unit of the period of change in the velocity- Returns:
- the combined velocity unit
-
getBaseUnit
Description copied from class:Unit
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
- Overrides:
getBaseUnit
in classPerUnit<D extends Unit,
TimeUnit> - Returns:
- the base unit
-
getUnit
Gets the major unit being measured (eg Meters for Meters per Second).- Returns:
- the major unit
-
getPeriod
Gets the period unit of the velocity, eg Seconds or Milliseconds.- Returns:
- the period unit
-
of
Description copied from class:PerUnit
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.Note: When called on an object of type
PerUnit
(and not a subclass!), this method will always return aPer
instance. If you want to avoid casting, usePerUnit.ofNative(double)
that returns aPer
instance directly. -
ofBaseUnits
Description copied from class:PerUnit
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.Note: When called on an object of type
PerUnit
(and not a subclass!), this method will always return aPer
instance. If you want to avoid casting, usePerUnit.ofNativeBaseUnits(double)
that returns aPer
instance directly.- Overrides:
ofBaseUnits
in classPerUnit<D extends Unit,
TimeUnit> - Parameters:
baseUnitMagnitude
- the magnitude of the measure in terms of its base units.- Returns:
- the ratio measure
-
zero
Description copied from class:Unit
Gets 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:Unit
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 byUnit.of(double)
. Subclasses are encouraged to override this method to sharpen the return type. -
mutable
Description copied from class:PerUnit
Creates 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.Note: When called on an object of type
PerUnit
(and not a subclass!), this method will always return aMutPer
instance. -
per
Combines this velocity unit with a unit of a period of change to create an acceleration unit. -
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
-
convertFrom
Converts a measurement value in terms of another velocity unit to this unit.- Parameters:
magnitude
- the magnitude of the measurement in terms of the other velocity unitotherUnit
- the other velocity unit- Returns:
- the value of the measurement in terms of this unit
-