Package edu.wpi.first.units
Class ForceUnit
A unit of force like
Units.Newtons
.-
Method Summary
Modifier and TypeMethodDescriptionstatic ForceUnit
combine
(MassUnit mass, LinearAccelerationUnit acceleration) Combines a mass and (linear) acceleration to form a unit of force.double
convertFrom
(double magnitude, ForceUnit otherUnit) Converts a measurement value in terms of another unit to this unit.Gets the base unit of measurement that this unit is derived from.multAsTorque
(DistanceUnit distance) Multiplies this force unit by a unit of distance to create a unit of torque.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.MultUnit
combine, convertFrom, equals, hashCode, ofNative, ofNativeBaseUnits, toString, unitA, unitB
Methods inherited from class edu.wpi.first.units.Unit
equivalent, fromBaseUnits, getConverterFromBase, getConverterToBase, isBaseUnit, name, symbol, toBaseUnits
-
Method Details
-
combine
Combines a mass and (linear) acceleration to form a unit of force.- Parameters:
mass
- the unit of massacceleration
- the unit of acceleration- Returns:
- the combined unit of force
-
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 classMultUnit<MassUnit,
LinearAccelerationUnit> - Returns:
- the base unit
-
multAsTorque
Multiplies this force unit by a unit of distance to create a unit of torque.- Parameters:
distance
- the unit of distance- Returns:
- the combined torque unit
-
of
Description copied from class:MultUnit
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
MultUnit
(and not a subclass!), this method will always return aMult
instance. If you want to avoid casting, useMultUnit.ofNativeBaseUnits(double)
that returns aPer
instance directly.- Overrides:
of
in classMultUnit<MassUnit,
LinearAccelerationUnit> - Parameters:
magnitude
- the magnitude of the measure in terms of its base units.- Returns:
- the measurement object
-
ofBaseUnits
Description copied from class:MultUnit
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
MultUnit
(and not a subclass!), this method will always return aMult
instance. If you want to avoid casting, useMultUnit.ofNativeBaseUnits(double)
that returns aPer
instance directly.- Overrides:
ofBaseUnits
in classMultUnit<MassUnit,
LinearAccelerationUnit> - Parameters:
baseUnitMagnitude
- the magnitude of the measure in terms of its base units.- Returns:
- the measurement object
-
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 classMultUnit<MassUnit,
LinearAccelerationUnit> - 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 classMultUnit<MassUnit,
LinearAccelerationUnit> - Returns:
- a measure of magnitude 1.0 in terms of this unit
-
mutable
Description copied from class:Unit
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.- Overrides:
mutable
in classMultUnit<MassUnit,
LinearAccelerationUnit> - Parameters:
initialMagnitude
- the initial magnitude of the mutable measurement- Returns:
- the mutable measurement object
-
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 classMultUnit<MassUnit,
LinearAccelerationUnit> - 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 unit to this unit.- Parameters:
magnitude
- the magnitude of the measurement in terms of the other unitotherUnit
- the other unit- Returns:
- the value of the measurement in terms of this unit
-