ADTF
3.18.2
|
Class for unit conversions. More...
Public Member Functions | |
tResult | Convert (tFloat64 *pf64Value, const cString &strUnitSource, const cString &strUnitDestination="SI") |
Unit Conversion. More... | |
tResult | Convert (tFloat64 *pf64Value, tUInt eUnitSource, tUInt eUnitDestination=UNIT_SI) |
Unit Conversion. More... | |
tResult | AddNewUnitString (tUInt eUnitIdentifier, const cString &strUnitString) |
This method adds a new identifier string for a unit. More... | |
tUInt | AddNewBaseUnit () |
This method adds a base unit to the UnitConverter and returns the created identifier handle. More... | |
tUInt | AddNewDerivedUnit (tUInt eUnitBase, tFloat64 fNumerator, tFloat64 fDenominator=1.0, tFloat64 fOffset=0.0) |
This method adds a derived unit to the UnitConverter. More... | |
tUInt | GetUnitIdentifier (const cString &strUnit) |
This method returns the handle of the unit corresponding to the input string. More... | |
Class for unit conversions.
The cUnitConversion supports as-is the following unit identifier and associated unit strings.
In the table the degree sign (\xB0) and the superscript two sign (\xB2) are represented by there escape sequences.
Unit Identifier | Unit Strings |
UNIT_METRE | m |
UNIT_MILLIMETRE | mm |
UNIT_CENTIMETRE | cm |
UNIT_KILOMETRE | km |
UNIT_MILES | miles |
UNIT_METRES_PER_SECOND | m/s, ms^-1, m*s^-1 |
UNIT_KILOMETRES_PER_HOUR | km/h |
UNIT_MILES_PER_HOUR | mph |
UNIT_METRES_PER_SECOND_SQUARED | m/s2, ms^-2, m/s^2, m*s^-2, m/s\xB2 |
UNIT_GRAVITATION | g |
UNIT_MILLIGRAVITATION | mg |
UNIT_RADIAN | rad |
UNIT_DEGREE | grad, \xB0 |
UNIT_RADIANS_PER_SECOND | rad/s, rad/sec, rad/sek, radiant/s, radiant/sec, radiant/sek |
UNIT_DEGREES_PER_SECOND | \xB0/s, grad/s, grad/sec, grad/sek, \xB0/sec, \xB0/sek |
UNIT_SECOND | s, sec, sek |
UNIT_MICROSECOND | us |
UNIT_MILLISECOND | ms |
UNIT_MINUTE | min |
UNIT_HOUR | h |
UNIT_DEGREE_CELSIUS | C |
UNIT_DEGREE_FAHRENHEIT | F |
Every unit conversion object can be extended to support even more units and units strings
Definition at line 51 of file unitconversion.h.
tUInt AddNewBaseUnit | ( | ) |
This method adds a base unit to the UnitConverter and returns the created identifier handle.
tUInt AddNewDerivedUnit | ( | tUInt | eUnitBase, |
tFloat64 | fNumerator, | ||
tFloat64 | fDenominator = 1.0 , |
||
tFloat64 | fOffset = 0.0 |
||
) |
This method adds a derived unit to the UnitConverter.
The last three arguments form a linear transformation from the derived unit to the base unit: fNumerator * UNIT_NEW / fDemoninator + fOffset = UNIT_BASE All existing conversions from the base unit to others units are translated to conversions from the derived unit to the other unit.
eUnitBase | [in] handle of the base unit |
fNumerator | [in] part of the linear transformation |
fDenominator | [in] part of the linear transformation |
fOffset | [in] part of the linear transformation |
This method adds a new identifier string for a unit.
eUnitIdentifier | [in] unit for which a new string shall be added |
strUnitString | [in] new identifier string |
tResult Convert | ( | tFloat64 * | pf64Value, |
const cString & | strUnitSource, | ||
const cString & | strUnitDestination = "SI" |
||
) |
Unit Conversion.
This method converts a float value from one unit to another.
pf64Value | [inout] float value to convert |
strUnitSource | [in] description string of source unit |
strUnitDestination | [in] description string of unit to convert to |
Unit Conversion.
This method converts a float value from one unit to another.
pf64Value | [inout] float value to convert |
eUnitSource | [in] handle of the source unit |
eUnitDestination | [in] handle of the unit to convert to |
This method returns the handle of the unit corresponding to the input string.
strUnit | [in] unit identifier string |