Provides the unit system management system as inspired from JSR-275.
Package Specification
The unit package provides a number of notions:
The Dimension class
The physical magnitudes are organized as a combination of 7 elementary dimensions which are:
- The temperature
- The duration
- The mass
- The length
- The amount of substance
- The electric intensity
- The luminous intensity
More concretely, a physical magnitude dimension is represented as the integral powers of these seven elementary dimensions. For example, a force is
a mass (power 1) by a distance (power 1) divided by seconds squared (power -2). All the other dimensions have power 0. We can obtain
new dimensions by multiplying and dividing dimensions as well as taking their power and root. If the powers are all 0, the dimension is
the origin of the physical quantities called ONE.
Two dimensions are compatible if they have the same powers for the same elementary dimensions. A dimension contains another if
the other powers are inferior or equal to the dimension powers. They are equal if they contain each-other, or equally if they are compatible.
In this package, we assume that a unit is non-ambiguously characterized by its dimension. Therefore units are compatible if and only if
their dimensions are.
The OrderOfMagnitude class
An order of magnitude is a multiplier to convert between compatible units. They are expressed as powers of 10 and have well defined
names in the international standards. The power zero of 10 is called UNIT.
The Unit classes
A unit is an object (called a standard) used as a reference to measure a physical quantity. It may have an associated symbol and
can be build from other units by conversion. They are expected to be organized in unit systems. A unit system is defined by a set
of base units and a set of units obtained by conversion (the derived units), by multiplication or division (the multiply units) or
by cloning (the alternate units). In the international standards, the base units are associated to each of the 7 elementary
dimensions but any set of base units can be defined as such. The base unit whose dimension is ONE is called DIMENSIONLESS.
The UnitConverter classes
A unit converter converts back and forth between two units linked by a conversion. The possible conversion are the multiplication/division (including by a
rational number for better precision), addition/subtraction and logarithm/exponential.
The exceptions
There are only two possible exceptions: either two units are not compatible (they do not have the same dimension) or they are not convertible (one
of the conversions in-between is not linear and, therefore, cannot be reversed). In both cases, the conversion fails.