Package edu.wpi.first.units
Interface Measure<U extends Unit>
- Type Parameters:
U
- the unit type of the measure
- All Superinterfaces:
Comparable<Measure<U>>
- All Known Subinterfaces:
Acceleration<D>
,Angle
,AngularAcceleration
,AngularMomentum
,AngularVelocity
,Current
,Dimensionless
,Distance
,Energy
,Force
,Frequency
,LinearAcceleration
,LinearMomentum
,LinearVelocity
,Mass
,MomentOfInertia
,Mult<A,
,B> MutableMeasure<U,
,Base, MutSelf> Per<Dividend,
,Divisor> Power
,Resistance
,Temperature
,Time
,Torque
,Velocity<D>
,Voltage
- All Known Implementing Classes:
GenericMutableMeasureImpl
,ImmutableAcceleration
,ImmutableAngle
,ImmutableAngularAcceleration
,ImmutableAngularMomentum
,ImmutableAngularVelocity
,ImmutableCurrent
,ImmutableDimensionless
,ImmutableDistance
,ImmutableEnergy
,ImmutableForce
,ImmutableFrequency
,ImmutableLinearAcceleration
,ImmutableLinearMomentum
,ImmutableLinearVelocity
,ImmutableMass
,ImmutableMeasure
,ImmutableMomentOfInertia
,ImmutableMult
,ImmutablePer
,ImmutablePower
,ImmutableResistance
,ImmutableTemperature
,ImmutableTime
,ImmutableTorque
,ImmutableVelocity
,ImmutableVoltage
,MutableMeasureBase
,MutAcceleration
,MutAngle
,MutAngularAcceleration
,MutAngularMomentum
,MutAngularVelocity
,MutCurrent
,MutDimensionless
,MutDistance
,MutEnergy
,MutForce
,MutFrequency
,MutLinearAcceleration
,MutLinearMomentum
,MutLinearVelocity
,MutMass
,MutMomentOfInertia
,MutMult
,MutPer
,MutPower
,MutResistance
,MutTemperature
,MutTime
,MutTorque
,MutVelocity
,MutVoltage
A measure holds the magnitude and unit of some dimension, such as distance, time, or speed. Two
measures with the same unit and magnitude are effectively equivalent objects.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
The threshold for two measures to be considered equivalent if converted to the same unit. -
Method Summary
Modifier and TypeMethodDescriptiondefault double
Absolute value of measure.default U
baseUnit()
A convenience method to get the base unit of the measurement.double
Gets the magnitude of this measure in terms of the base unit.default int
copy()
Returns an immutable copy of this measure.default double
Take the sign of another measure.div
(double divisor) Divides this measure by a unitless scalar and returns the result.default Measure<?>
div
(Acceleration<?> divisor) Divides this measure by a generic acceleration and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by an angle and returns the result in the most appropriate unit.default Measure<?>
div
(AngularAcceleration divisor) Divides this measure by an angular acceleration and returns the result in the most appropriate unit.default Measure<?>
div
(AngularMomentum divisor) Divides this measure by an angular momentum and returns the result in the most appropriate unit.default Measure<?>
div
(AngularVelocity divisor) Divides this measure by an angular velocity and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by an electric current and returns the result in the most appropriate unit.div
(Dimensionless divisor) Divides this measure by a dimensionless scalar and returns the result.default Measure<?>
Divides this measure by a distance and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by an energy and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by a force and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by a frequency and returns the result in the most appropriate unit.default Measure<?>
div
(LinearAcceleration divisor) Divides this measure by a linear acceleration and returns the result in the most appropriate unit.default Measure<?>
div
(LinearMomentum divisor) Divides this measure by a linear momentum and returns the result in the most appropriate unit.default Measure<?>
div
(LinearVelocity divisor) Divides this measure by a linear velocity and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by a mass and returns the result in the most appropriate unit.default Measure<?>
div
(MomentOfInertia divisor) Divides this measure by a moment of inertia and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by a generic multiplication and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by a generic ratio and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by a power and returns the result in the most appropriate unit.default Measure<?>
div
(Resistance divisor) Divides this measure by a resistance and returns the result in the most appropriate unit.default Measure<?>
div
(Temperature divisor) Divides this measure by a temperature and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by a time and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by a torque and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by a generic velocity and returns the result in the most appropriate unit.default Measure<?>
Divides this measure by a voltage and returns the result in the most appropriate unit.default Measure<?>
Divides this measurement by another measure and performs some dimensional analysis to reduce the units.divide
(double divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
divide
(Acceleration<?> divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
divide
(AngularAcceleration divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
divide
(AngularMomentum divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
divide
(AngularVelocity divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.divide
(Dimensionless divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
divide
(LinearAcceleration divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
divide
(LinearMomentum divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
divide
(LinearVelocity divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
divide
(MomentOfInertia divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
divide
(Resistance divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
divide
(Temperature divisor) Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.default Measure<?>
Deprecated, for removal: This API element is subject to removal in a future version.use div instead.divideRatio
(Measure<? extends PerUnit<? extends U, Other>> divisor) Divides this measure by a ratio in terms of this measurement's unit to another unit, returning a measurement in terms of the other unit.default boolean
Checks if this measure is greater than another measure of the same unit.default boolean
Checks if this measure is greater than or equivalent to another measure of the same unit.default double
Converts this measure to a measure with a different unit of the same type, eg minutes to seconds.default boolean
isEquivalent
(Measure<?> other) Checks if this measure is equivalent to another measure of the same unit.default boolean
Checks if this measure is near another measure of the same unit.default boolean
Checks if this measure is near another measure of the same unit, with a specified tolerance of the same unit.default boolean
Checks if this measure is less than another measure of the same unit.default boolean
Checks if this measure is less than or equivalent to another measure of the same unit.double
Gets the unitless magnitude of this measure.Returns the measure with the absolute value closest to positive infinity.Returns the measure with the absolute value closest to negative infinity.Subtracts another measure of the same unit type from this one.MutableMeasure<U,
?, ?> Returns a mutable copy of this measure.negate()
Deprecated, for removal: This API element is subject to removal in a future version.use unaryMinus() instead.default Measure<?>
Divides this measure by a time period and returns the result in the most appropriate unit.Adds another measure of the same unit type to this one.times
(double multiplier) Multiplies this measure by a scalar unitless multiplier.default Measure<?>
times
(Acceleration<?> multiplier) Multiplies this measure by an acceleration and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by an angle and returns the resulting measure in the most appropriate unit.default Measure<?>
times
(AngularAcceleration multiplier) Multiplies this measure by an angular acceleration and returns the resulting measure in the most appropriate unit.default Measure<?>
times
(AngularMomentum multiplier) Multiplies this measure by an angular momentum and returns the resulting measure in the most appropriate unit.default Measure<?>
times
(AngularVelocity multiplier) Multiplies this measure by an angular velocity and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by an electric current and returns the resulting measure in the most appropriate unit.times
(Dimensionless multiplier) Multiplies this measure by a scalar dimensionless multiplier.default Measure<?>
Multiplies this measure by a distance and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by an energy and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by a force and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by a frequency and returns the resulting measure in the most appropriate unit.default Measure<?>
times
(LinearAcceleration multiplier) Multiplies this measure by a linear acceleration and returns the resulting measure in the most appropriate unit.default Measure<?>
times
(LinearMomentum multiplier) Multiplies this measure by a linear momentum and returns the resulting measure in the most appropriate unit.default Measure<?>
times
(LinearVelocity multiplier) Multiplies this measure by a linear velocity and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by a mass and returns the resulting measure in the most appropriate unit.default Measure<?>
times
(MomentOfInertia multiplier) Multiplies this measure by a moment of intertia and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by a generic multiplied measure and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by a generic ratio measurement and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by a power and returns the resulting measure in the most appropriate unit.default Measure<?>
times
(Resistance multiplier) Multiplies this measure by a resistance and returns the resulting measure in the most appropriate unit.default Measure<?>
times
(Temperature multiplier) Multiplies this measure by a temperature and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by a time and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by a torque and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by a generic velocity and returns the resulting measure in the most appropriate unit.default Measure<?>
Multiplies this measure by a voltage and returns the resulting measure in the most appropriate unit.default Measure<?>
Generates a new measure that is equal to this measure multiplied by another.timesConversionFactor
(Measure<? extends PerUnit<Other, U>> conversionFactor) Multiplies this measure by a conversion factor, returning the converted measurement.default Dimensionless
timesInverse
(Measure<? extends PerUnit<DimensionlessUnit, ? extends U>> multiplier) Multiplies this measure by another measurement of the inverse unit type (eg Time multiplied by Frequency) and returns the resulting dimensionless measure.timesRatio
(Measure<? extends PerUnit<? extends Other, U>> ratio) Multiplies this measure by another measurement of something over the unit type (eg Time multiplied by LinearVelocity) and returns the resulting measure of the ratio's dividend unit.default String
Returns a string representation of this measurement in a longhand form.default String
Returns a string representation of this measurement in a shorthand form.Returns a measure equivalent to this one equal to zero minus its current value.unit()
Gets the units of this measure.
-
Field Details
-
EQUIVALENCE_THRESHOLD
The threshold for two measures to be considered equivalent if converted to the same unit. This is only needed due to floating-point error.- See Also:
-
-
Method Details
-
magnitude
double magnitude()Gets the unitless magnitude of this measure.- Returns:
- the magnitude in terms of
the unit
.
-
baseUnitMagnitude
double baseUnitMagnitude()Gets the magnitude of this measure in terms of the base unit. If the unit is the base unit for its system of measure, then the value will be equivalent tomagnitude()
.- Returns:
- the magnitude in terms of the base unit
-
unit
Gets the units of this measure.- Returns:
- the unit
-
in
Converts this measure to a measure with a different unit of the same type, eg minutes to seconds. Converting to the same unit is equivalent to callingmagnitude()
.Meters.of(12).in(Feet) // 39.3701 Seconds.of(15).in(Minutes) // 0.25
- Parameters:
unit
- the unit to convert this measure to- Returns:
- the value of this measure in the given unit
-
baseUnit
A convenience method to get the base unit of the measurement. Equivalent tounit().getBaseUnit()
.- Returns:
- the base unit of measure.
-
abs
Absolute value of measure.- Parameters:
unit
- unit to use- Returns:
- the absolute value of this measure in the given unit
-
copySign
Take the sign of another measure.- Parameters:
other
- measure from which to take signunit
- unit to use- Returns:
- the value of the measure in the given unit with the sign of the provided measure
-
copy
Returns an immutable copy of this measure. The copy can be used freely and is guaranteed never to change.- Returns:
- the copied measure
-
mutableCopy
MutableMeasure<U,?, mutableCopy()?> Returns a mutable copy of this measure. It will be initialized to the current state of this measure, but can be changed over time without needing to allocate new measurement objects.- Returns:
- the copied measure
-
unaryMinus
Measure<U> unaryMinus()Returns a measure equivalent to this one equal to zero minus its current value. For non-linear unit types like temperature, the zero point is treated as the zero value of the base unit (eg Kelvin). In effect, this means code likeCelsius.of(10).unaryMinus()
returns a value equivalent to -10 Kelvin, and not -10° Celsius.- Returns:
- a measure equal to zero minus this measure
-
negate
Deprecated, for removal: This API element is subject to removal in a future version.use unaryMinus() instead. This was renamed for consistency with other WPILib classes like Rotation2dReturns a measure equivalent to this one equal to zero minus its current value. For non-linear unit types like temperature, the zero point is treated as the zero value of the base unit (eg Kelvin). In effect, this means code likeCelsius.of(10).negate()
returns a value equivalent to -10 Kelvin, and not -10° Celsius.- Returns:
- a measure equal to zero minus this measure
-
plus
Adds another measure of the same unit type to this one.- Parameters:
other
- the measurement to add- Returns:
- a measure of the sum of both measures
-
minus
Subtracts another measure of the same unit type from this one.- Parameters:
other
- the measurement to subtract- Returns:
- a measure of the difference between the measures
-
times
Multiplies this measure by a scalar unitless multiplier.- Parameters:
multiplier
- the scalar multiplication factor- Returns:
- the scaled result
-
times
Multiplies this measure by a scalar dimensionless multiplier.- Parameters:
multiplier
- the scalar multiplication factor- Returns:
- the scaled result
-
times
Generates a new measure that is equal to this measure multiplied by another. Some dimensional analysis is performed to reduce the units down somewhat; for example, multiplying aMeasure<Time>
by aMeasure<Velocity<Distance>>
will return just aMeasure<Distance>
instead of the naiveMeasure<Mult<Time, Velocity<Distance>>
. This is not guaranteed to perform perfect dimensional analysis.- Parameters:
multiplier
- the unit to multiply by- Returns:
- the multiplicative unit
-
times
Multiplies this measure by an acceleration and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by an angle and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by an angular acceleration and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by an angular momentum and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by an angular velocity and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by an electric current and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a distance and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by an energy and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a force and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a frequency and returns the resulting measure in the most appropriate unit. This often - but not always - means implementations return a variation of aPer
measure.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a linear acceleration and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a linear momentum and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a linear velocity and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a mass and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a moment of intertia and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a generic multiplied measure and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a power and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a generic ratio measurement and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a temperature and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a time and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a torque and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a generic velocity and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a voltage and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
times
Multiplies this measure by a resistance and returns the resulting measure in the most appropriate unit.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
timesConversionFactor
default <Other extends Unit,M extends Measure<Other>> M timesConversionFactor(Measure<? extends PerUnit<Other, U>> conversionFactor) Multiplies this measure by a conversion factor, returning the converted measurement. Unliketimes(Per)
, this allows for basic unit cancellation to return measurements of a known dimension.- Type Parameters:
Other
- the unit type to convert toM
- the concrete return unit type. Note: the conversion factor's numerator unit must return instances of this type fromUnit.ofBaseUnits(double)
}- Parameters:
conversionFactor
- the conversion factor by which to multiply- Returns:
- the converted result
-
timesInverse
default Dimensionless timesInverse(Measure<? extends PerUnit<DimensionlessUnit, ? extends U>> multiplier) Multiplies this measure by another measurement of the inverse unit type (eg Time multiplied by Frequency) and returns the resulting dimensionless measure.- Parameters:
multiplier
- the measurement to multiply by.- Returns:
- the multiplication result
-
timesRatio
default <Other extends Unit> Measure<Other> timesRatio(Measure<? extends PerUnit<? extends Other, U>> ratio) Multiplies this measure by another measurement of something over the unit type (eg Time multiplied by LinearVelocity) and returns the resulting measure of the ratio's dividend unit.- Type Parameters:
Other
- other unit that the results are in terms of- Parameters:
ratio
- the measurement to multiply by.- Returns:
- the multiplication result
-
div
Divides this measure by a unitless scalar and returns the result.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a dimensionless scalar and returns the result.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measurement by another measure and performs some dimensional analysis to reduce the units.- Parameters:
divisor
- the unit to divide by- Returns:
- the resulting measure
-
div
Divides this measure by a generic acceleration and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by an angle and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by an angular acceleration and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by an angular momentum and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by an angular velocity and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by an electric current and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a distance and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by an energy and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a force and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a frequency and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a linear acceleration and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a linear momentum and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a linear velocity and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a mass and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a moment of inertia and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a generic multiplication and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a power and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a generic ratio and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a temperature and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a time and returns the result in the most appropriate unit. This will often - but not always - result in aPer
type likeLinearVelocity
orAcceleration
.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a torque and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a generic velocity and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a voltage and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
div
Divides this measure by a resistance and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a unitless scalar and returns the result.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a dimensionless scalar and returns the result.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measurement by another measure and performs some dimensional analysis to reduce the units.- Parameters:
divisor
- the unit to divide by- Returns:
- the resulting measure
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a generic acceleration and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by an angle and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by an angular acceleration and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by an angular momentum and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by an angular velocity and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by an electric current and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a distance and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by an energy and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a force and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a frequency and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a linear acceleration and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a linear momentum and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a linear velocity and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a mass and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a moment of inertia and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a generic multiplication and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a power and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a generic ratio and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a temperature and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a time and returns the result in the most appropriate unit. This will often - but not always - result in aPer
type likeLinearVelocity
orAcceleration
.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a torque and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a generic velocity and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a voltage and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divide
Deprecated, for removal: This API element is subject to removal in a future version.use div instead. This was renamed for consistency with other languages like KotlinDivides this measure by a resistance and returns the result in the most appropriate unit.- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
divideRatio
default <Other extends Unit> Measure<Other> divideRatio(Measure<? extends PerUnit<? extends U, Other>> divisor) Divides this measure by a ratio in terms of this measurement's unit to another unit, returning a measurement in terms of the other unit.- Type Parameters:
Other
- the other unit that results are in terms of- Parameters:
divisor
- the measurement to divide by.- Returns:
- the division result
-
per
Divides this measure by a time period and returns the result in the most appropriate unit. This is equivalent todiv(period.of(1))
.- Parameters:
period
- the time period measurement to divide by.- Returns:
- the division result
-
isNear
Checks if this measure is near another measure of the same unit. Provide a variance threshold for use for a +/- scalar, such as 0.05 for +/- 5%.Inches.of(11).isNear(Inches.of(10), 0.1) // true Inches.of(12).isNear(Inches.of(10), 0.1) // false
- Parameters:
other
- the other measurement to compare againstvarianceThreshold
- the acceptable variance threshold, in terms of an acceptable +/- error range multiplier. Checking if a value is within 10% means a value of 0.1 should be passed; checking if a value is within 1% means a value of 0.01 should be passed, and so on.- Returns:
- true if this unit is near the other measure, otherwise false
-
isNear
Checks if this measure is near another measure of the same unit, with a specified tolerance of the same unit.Meters.of(1).isNear(Meters.of(1.2), Millimeters.of(300)) // true Degrees.of(90).isNear(Rotations.of(0.5), Degrees.of(45)) // false
- Parameters:
other
- the other measure to compare against.tolerance
- the tolerance allowed in which the two measures are defined as near each other.- Returns:
- true if this unit is near the other measure, otherwise false.
-
isEquivalent
Checks if this measure is equivalent to another measure of the same unit.- Parameters:
other
- the measure to compare to- Returns:
- true if this measure is equivalent, false otherwise
-
compareTo
- Specified by:
compareTo
in interfaceComparable<U extends Unit>
-
gt
Checks if this measure is greater than another measure of the same unit.- Parameters:
o
- the other measure to compare to- Returns:
- true if this measure has a greater equivalent magnitude, false otherwise
-
gte
Checks if this measure is greater than or equivalent to another measure of the same unit.- Parameters:
o
- the other measure to compare to- Returns:
- true if this measure has an equal or greater equivalent magnitude, false otherwise
-
lt
Checks if this measure is less than another measure of the same unit.- Parameters:
o
- the other measure to compare to- Returns:
- true if this measure has a lesser equivalent magnitude, false otherwise
-
lte
Checks if this measure is less than or equivalent to another measure of the same unit.- Parameters:
o
- the other measure to compare to- Returns:
- true if this measure has an equal or lesser equivalent magnitude, false otherwise
-
max
Returns the measure with the absolute value closest to positive infinity.- Type Parameters:
U
- the type of the units of the measures- Parameters:
measures
- the set of measures to compare- Returns:
- the measure with the greatest positive magnitude, or null if no measures were provided
-
min
Returns the measure with the absolute value closest to negative infinity.- Type Parameters:
U
- the type of the units of the measures- Parameters:
measures
- the set of measures to compare- Returns:
- the measure with the greatest negative magnitude
-
toShortString
Returns a string representation of this measurement in a shorthand form. The symbol of the backing unit is used, rather than the full name, and the magnitude is represented in scientific notation.- Returns:
- the short form representation of this measurement
-
toLongString
Returns a string representation of this measurement in a longhand form. The name of the backing unit is used, rather than its symbol, and the magnitude is represented in a full string, not scientific notation. (Very large values may be represented in scientific notation, however)- Returns:
- the long form representation of this measurement
-