Class PowerUnit
This is the base type for units of power dimension. It is also used to specify the dimension
for Measure
: Measure<PowerUnit>
.
Actual units (such as Units.Watts
and Units.Horsepower
) can be found in the
Units
class.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PowerUnit
combine
(AngularVelocityUnit angularVelocity, TorqueUnit torque) Combines angular velocity and torque into power.static PowerUnit
combine
(CurrentUnit current, VoltageUnit voltage) Combines voltage and current into power.static PowerUnit
combine
(EnergyUnit energy, TimeUnit period) Combines an energy and a time unit to form a unit of power.static PowerUnit
combine
(TorqueUnit torque, AngularVelocityUnit angularVelocity) Combines angular velocity and torque into power.static PowerUnit
combine
(VoltageUnit voltage, CurrentUnit current) Combines voltage and current into power.double
convertFrom
(double magnitude, PowerUnit otherUnit) Converts a measurement value in terms of another power 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.Combines this unit with a unit of time.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.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 an energy and a time unit to form a unit of power.- Parameters:
energy
- the unit of energyperiod
- the unit of time- Returns:
- the combined unit of power
-
combine
Combines voltage and current into power.- Parameters:
voltage
- the unit of voltagecurrent
- the unit of current- Returns:
- the combined unit of power
-
combine
Combines voltage and current into power.- Parameters:
current
- the unit of currentvoltage
- the unit of voltage- Returns:
- the combined unit of power
-
combine
Combines angular velocity and torque into power. Useful when dealing with motors and flywheels.- Parameters:
angularVelocity
- the unit of angular velocitytorque
- the unit of torque- Returns:
- the combined unit of power
-
combine
Combines angular velocity and torque into power. Useful when dealing with motors and flywheels.- Parameters:
torque
- the unit of torqueangularVelocity
- the unit of angular velocity- Returns:
- the combined unit of power
-
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<EnergyUnit,
TimeUnit> - Returns:
- the base 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.- Overrides:
of
in classPerUnit<EnergyUnit,
TimeUnit> - Parameters:
magnitude
- the magnitude of the measure- Returns:
- the ratio measure
-
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<EnergyUnit,
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.- Overrides:
zero
in classPerUnit<EnergyUnit,
TimeUnit> - Returns:
- a zero-magnitude measure of this unit
-
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.- Overrides:
one
in classPerUnit<EnergyUnit,
TimeUnit> - Returns:
- a measure of magnitude 1.0 in terms of this unit
-
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.- Overrides:
mutable
in classPerUnit<EnergyUnit,
TimeUnit> - Parameters:
initialMagnitude
- the starting magnitude of the measure- Returns:
- the ratio measure
-
per
Description copied from class:Unit
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.- Overrides:
per
in classPerUnit<EnergyUnit,
TimeUnit> - Parameters:
time
- the unit of time- Returns:
- the combined 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 power unit to this unit.- Parameters:
magnitude
- the magnitude of the measurement in terms of the other power unitotherUnit
- the other power unit- Returns:
- the value of the measurement in terms of this unit
-