UoM .Net
Unit Class Reference

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...
 

Detailed Description

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.

Author
Petroware AS

Constructor & Destructor Documentation

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.

Parameters
nameName of unit such as "meter". Non-null.
symbolSymbol of unit such as "m". Non-null.
aConversion factor a for converting to base unit.
bConversion factor b for converting to base unit.
cConversion factor c for converting to base unit.
dConversion factor d for converting to base unit.
Exceptions
ArgumentNullExceptionIf name or symbol is null.

Member Function Documentation

double FromBase ( double  baseValue)

Convert the specified value given in base unit to this unit.

Parameters
baseValueBase value to convert.
Returns
Value converted to this unit.
string GetName ( )

Return name of this unit.

Returns
Name of this unit. Never null.
string GetSymbol ( )

Return symbol of this unit.

Returns
Symbol of this unit. Never null.
double ToBase ( double  value)

Convert the specified value to base unit in the quantity of this unit.

Parameters
valueValue to convert.
Returns
Value converted to base unit.

The documentation for this class was generated from the following file: