Commonly useful functionality for PhysicalQuantity.
Provides arithmetic, equals/hashCode, comparison, toString.
- Implemented types
Constructors
- PhysicalQuantities(Measurement magnitude, T unit)
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- magnitude → Measurement
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- unit → T
-
final
Methods
-
baseUnit(
Measurement q) → PhysicalQuantities< T> -
compareTo(
PhysicalQuantities< T> other) → int -
Compares this object to another object.
override
-
fundamental(
) → Measurement -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
It may seem strange to only define (+,-) without (*,/)...
but conceptually things get tricky.
2 kg * 4 kg = 8 kg^2.
2 kg / 4 kg = 0.5 (no unit)
These results are computational devices.
They are not "masses." What is the return type?
kg^2 is used within the context of gravitational attraction, but only
as a factor for calculations-- it doesn't have much conceptual meaning.
Multiplication might result in a single unit raised to a power or u1 * u2
Division might result in only a
NumericalValue
or u1 / u2. That complexity would make the API difficult to understand; although rigourously correct. This is all very interesting and discussed in: https://en.wikipedia.org/wiki/Unit_of_measurement#Units_as_dimensions and https://en.wikipedia.org/wiki/Quantity_calculus I'm not a physicist and I don't need it, so, punting. :Poverride -
toUnit(
T u) → PhysicalQuantity< T> -
inherited
Operators
-
operator +(
PhysicalQuantities< T> o) → PhysicalQuantities<T> -
operator -(
PhysicalQuantities< T> o) → PhysicalQuantities<T> -
operator <(
PhysicalQuantities< T> o) → bool -
operator <=(
PhysicalQuantities< T> o) → bool -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
PhysicalQuantities< T> o) → bool -
operator >=(
PhysicalQuantities< T> o) → bool