Model a unit, such as "ft", "m", "N", "Hz", "m/s" etc., and how values converts to the base unit of the same quantity. More...
Public Member Functions | |
override bool | Equals (object o) |
double | FromBase (double baseValue) |
Convert the specified value given in base unit to this unit. More... | |
override int | GetHashCode () |
string | GetName () |
Return name of this unit. More... | |
string | GetSymbol () |
Return symbol of this unit. More... | |
double | ToBase (double value) |
Convert the specified value to base unit in the quantity of this unit. More... | |
override string | ToString () |
Unit (string name, string symbol, double a, double b, double c, double d) | |
Create a new unit. More... | |
Model a unit, such as "ft", "m", "N", "Hz", "m/s" etc., and how values converts to the base unit of the same quantity.
This class is immutable.
Unit | ( | string | name, |
string | symbol, | ||
double | a, | ||
double | b, | ||
double | c, | ||
double | d | ||
) |
Create a new unit.
The conversion consists of four factors that are applied as follows when value is to be converted to base unit:
base = (a * value + b) / (c * value + d);
For most conversion only a is needed. In these cases b, c and d should be set to 0.0, 0.0 and 1.0 respectively. For units like temperature a shift (b) is used as well, while c and d is in practice never used.
name | Name of unit such as "meter". Non-null. |
symbol | Symbol of unit such as "m". Non-null. |
a | Conversion factor a for converting to base unit. |
b | Conversion factor b for converting to base unit. |
c | Conversion factor c for converting to base unit. |
d | Conversion factor d for converting to base unit. |
ArgumentNullException | If name or symbol is null. |
double FromBase | ( | double | baseValue | ) |
Convert the specified value given in base unit to this unit.
baseValue | Base value to convert. |
string GetName | ( | ) |
Return name of this unit.
string GetSymbol | ( | ) |
Return symbol of this unit.
double ToBase | ( | double | value | ) |
Convert the specified value to base unit in the quantity of this unit.
value | Value to convert. |