Units mixin
A unit is a particular physical quantity, defined and adopted by convention, with which other particular quantities of the same kind (dimensions) are compared to express their value.
The Units class represents a unit and includes a name (plural), an optional intermediate abbreviation, an optional symbol and an optional singular form. A Units object stores a conversion value (to convert a value to SI-MKS units) and dimensions.
Abstract Units Mixin
This class is designed to be used as a mixin. In this way typed units
wind up being quantities themselves, extending the associated quantity type
and mixing in units to represent themselves as units objects (e.g.,
LengthUnits extends Length with Units
). This is
consistent with the definition of units as quantities with specific values
and means also that units objects are quantity objects and can be used
as quantity parameters.
'Units' vs. 'Unit'
Precisely speaking, quantities are expressed as multiples of a particular unit (singular, not plural). However, when the quantity's absolute value is greater than 1, the unit is pluralized when spoken. For example, one says 'five meters,' not 'five of the meter unit' or something along those lines. Therefore, to make units easier to work with and program, this package calls this class Units and not Unit and defines all static unit objects with plural names (e.g., meters vs. meter). This leads to a more natural expression upon Quantity object creation and value manipulation.
- Mixin applications
-
- AbsorbedDoseRateUnits
- AbsorbedDoseUnits
- AccelerationUnits
- ActivityUnits
- AmountOfSubstanceUnits
- AngleUnits
- AngularAccelerationUnits
- AngularMomentumUnits
- AngularSpeedUnits
- AreaUnits
- CapacitanceUnits
- CatalyticActivityUnits
- ChargeDensityUnits
- ChargeUnits
- ConcentrationUnits
- ConductanceUnits
- CurrencyUnits
- CurrentDensityUnits
- CurrentUnits
- DoseEquivalentUnits
- DynamicViscosityUnits
- ElectricFieldStrengthUnits
- ElectricFluxDensityUnits
- ElectricPotentialDifferenceUnits
- EnergyDensityUnits
- EnergyFluxUnits
- EnergyUnits
- EntropyUnits
- ExposureUnits
- ForceUnits
- FrequencyUnits
- HeatFluxDensityUnits
- IlluminanceUnits
- InductanceUnits
- InformationRateUnits
- InformationUnits
- KinematicViscosityUnits
- LengthUnits
- LevelUnits
- LuminanceUnits
- LuminousFluxUnits
- LuminousIntensityUnits
- MagneticFieldStrengthUnits
- MagneticFluxDensityUnits
- MagneticFluxUnits
- MassDensityUnits
- MassFlowRateUnits
- MassFluxDensityUnits
- MassUnits
- MolarEnergyUnits
- MolarEntropyUnits
- PermeabilityUnits
- PermittivityUnits
- PowerUnits
- PressureUnits
- RadianceUnits
- RadiantIntensityUnits
- ResistanceUnits
- ScalarUnits
- SolidAngleUnits
- SpecificEnergyUnits
- SpecificHeatCapacityUnits
- SpecificVolumeUnits
- SpectralIrradianceUnits
- SpeedUnits
- SurfaceTensionUnits
- TemperatureIntervalUnits
- TemperatureUnits
- ThermalConductivityUnits
- TimeInstantUnits
- TimeUnits
- TorqueUnits
- VolumeFlowRateUnits
- VolumeUnits
- WaveNumberUnits
Properties
- abbrev1 ↔ String?
-
The primary abbreviation for the units.
getter/setter pair
- abbrev2 ↔ String?
-
A secondary abbreviation for the units.
getter/setter pair
- alternateName → String?
-
Returns the alternate name for the units. This may be a non-standard
representation. If no alternate name exists, then null is returned.
no setter
- convToMKS ↔ Number
-
Multiply by this value to convert a Quantity in these units to SI-MKS units.
getter/setter pair
- hashCode → int
-
All units have a unique name.
no setteroverride
- metricBase ↔ bool
-
Whether these units are considered a base metric unit.
getter/setter pair
- name ↔ String
-
The name of the units (plural).
getter/setter pair
- offset ↔ double
-
The offset of this unit from zero in the metric unit scale.
getter/setter pair
- quantityType → Type
-
The Type to which the Units apply
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- singular ↔ String
-
The name of the units in singular form.
getter/setter pair
Methods
-
atto(
) → Units - Returns the derived Units having the 10^-18 prefix, atto (a).
-
centi(
) → Units - Returns the derived Units having the 10^-2 (i.e., 0.01) prefix, centi (c).
-
deci(
) → Units - Returns the derived Units having the 10^-1 (i.e., 0.1) prefix, deci (d).
-
deka(
) → Units - Returns the derived Units having the 10^1 (i.e. 10) prefix, deka (da).
-
derive(
String fullPrefix, String abbrevPrefix, double conv) → Units - Derive Units using this Units object as the base.
-
exa(
) → Units - Returns the derived Units having the 10^18 prefix, exa (E).
-
femto(
) → Units - Returns the derived Units having the 10^-15 prefix, femto (f).
-
fromMks(
dynamic mks) → Number -
Calculates and returns the value in the units represented by this Units
object of
mks
(that is expected to be in SI-MKS units). The method accepts a num or Number object; any other type will cause a QuantityException. -
getShortestName(
bool sing) → String -
Returns the shortest name for the units. This will be the first non-null name
found when inspecting secondary abbreviation, primary abbreviation and full name,
in that order. If
sing
is true and no symbol or alternate name are available then the singular version of the name will be returned. -
giga(
) → Units - Returns the derived Units having the 10^9 prefix, giga (G).
-
hecto(
) → Units - Returns the derived Units having the 10^2 (i.e., 100) prefix, hecto (h).
-
kilo(
) → Units - Returns the derived Units having the 10^3 (i.e., 1000) prefix, kilo (k).
-
mega(
) → Units - Returns the derived Units having the 10^6 prefix, mega (M).
-
micro(
) → Units - Returns the derived Units having the 10^-6 prefix, micro (the symbol mu).
-
milli(
) → Units - Returns the derived Units having the 10^-3 (i.e., 0.001) prefix, milli (m).
-
nano(
) → Units - Returns the derived Units having the 10^-9 prefix, nano (n).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
peta(
) → Units - Returns the derived Units having the 10^15 prefix, peta (P).
-
pico(
) → Units - Returns the derived Units having the 10^-12 prefix, pico (p).
-
tera(
) → Units - Returns the derived Units having the 10^12 prefix, tera (T).
-
toMks(
dynamic value) → Number -
Calculates and returns the value in SI-MKS units of the specified
value
(that is implicitly in these units). The method expectsvalue
to be a num or Number object; any other type will cause a QuantityException. -
toString(
) → String -
Returns a String representation of the Units in the following format:
override
-
yocto(
) → Units - Returns the derived Units having the 10^-24 prefix, yocto (y).
-
yotta(
) → Units - Returns the derived Units having the 10^24 prefix, yotta (Y).
-
zepto(
) → Units - Returns the derived Units having the 10^-21 prefix, zepto (z).
-
zetta(
) → Units - Returns the derived Units having the 10^21 prefix, zetta (Z).
Operators
-
operator ==(
Object obj) → bool -
Two units are considered equal if their conversions to MKS are equal and
they have the same singular name.
override