Unit conversion class to convert values between physical unit systems. More...
#include <unit_converter.h>
Public Member Functions | |
cUnitConverter (char const *_kind, char const *_name, char const *_symbol, double _factor=1.0, double _offset=0.0, int _decimal_places=1) | |
int | GetDecimalPlaces (void) const |
Return the number of decimal places for printing values in the external unit system. | |
double | GetFactor (void) const |
Return the conversion factor from internal to external units. | |
char const * | GetKind (void) const |
Return the kind of unit converted (something like "angle" or "time") | |
char const * | GetName (void) const |
Return the name of the external unit (something like "degrees" or "milliseconds") | |
double | GetOffset (void) const |
Return the conversion offset from internal to external units. | |
char const * | GetSymbol (void) const |
Return the symbol of the external unit (something like "deg" or "ms") | |
double | ToExternal (double internal) const |
cSimpleVector | ToExternal (cSimpleVector &internal) const |
std::vector< double > | ToExternal (std::vector< double > const &internal) const |
double | ToInternal (double external) const |
cSimpleVector | ToInternal (cSimpleVector &external) const |
std::vector< double > | ToInternal (std::vector< double > const &external) const |
Protected Attributes | |
int | decimal_places |
A usefull number of decimal places for printing values in the external unit system. | |
double | factor |
the conversion factor from internal to external units | |
char const * | kind |
the kind of unit to be converted (something like "angle" or "time") | |
char const * | name |
the name of the external unit (something like "degrees" or "milliseconds") | |
double | offset |
the conversion offset from internal to external units | |
char const * | symbol |
the symbol of the external unit (something like "deg" or "ms") |
Unit conversion class to convert values between physical unit systems.
An object of this class can be configured to convert values of a physical unit between 2 physical unit systems. An angle value given in degrees can e.g. be converted from/to radians or vice versa by an object of this class.
Definition at line 75 of file unit_converter.h.
cUnitConverter::cUnitConverter | ( | char const * | _kind, |
char const * | _name, | ||
char const * | _symbol, | ||
double | _factor = 1.0 , |
||
double | _offset = 0.0 , |
||
int | _decimal_places = 1 |
||
) |
Constructor of cUnitConverter class.
At construction time the conversion parameters - a factor and an offset - must be provided along with elements that describe the unit of a value
_kind | - a string describing the kind of unit to be converted (something like "angle" or "time") |
_name | - the name of the external unit (something like "degrees" or "milliseconds") |
_symbol | - the symbol of the external unit (something like "deg" or "ms") |
_factor | - the conversion factor from internal to external units |
_offset | - the conversion offset from internal to external units |
_decimal_places | - A usefull number of decimal places for printing values in the external unit system |
int cUnitConverter::GetDecimalPlaces | ( | void | ) | const |
Return the number of decimal places for printing values in the external unit system.
double cUnitConverter::GetFactor | ( | void | ) | const |
Return the conversion factor from internal to external units.
char const* cUnitConverter::GetKind | ( | void | ) | const |
Return the kind of unit converted (something like "angle" or "time")
char const* cUnitConverter::GetName | ( | void | ) | const |
Return the name of the external unit (something like "degrees" or "milliseconds")
double cUnitConverter::GetOffset | ( | void | ) | const |
Return the conversion offset from internal to external units.
char const* cUnitConverter::GetSymbol | ( | void | ) | const |
Return the symbol of the external unit (something like "deg" or "ms")
double cUnitConverter::ToExternal | ( | double | internal | ) | const |
cSimpleVector cUnitConverter::ToExternal | ( | cSimpleVector & | internal | ) | const |
std::vector<double> cUnitConverter::ToExternal | ( | std::vector< double > const & | internal | ) | const |
double cUnitConverter::ToInternal | ( | double | external | ) | const |
cSimpleVector cUnitConverter::ToInternal | ( | cSimpleVector & | external | ) | const |
std::vector<double> cUnitConverter::ToInternal | ( | std::vector< double > const & | external | ) | const |
int cUnitConverter::decimal_places [protected] |
A usefull number of decimal places for printing values in the external unit system.
Definition at line 198 of file unit_converter.h.
double cUnitConverter::factor [protected] |
the conversion factor from internal to external units
Definition at line 192 of file unit_converter.h.
char const* cUnitConverter::kind [protected] |
the kind of unit to be converted (something like "angle" or "time")
Definition at line 183 of file unit_converter.h.
char const* cUnitConverter::name [protected] |
the name of the external unit (something like "degrees" or "milliseconds")
Definition at line 186 of file unit_converter.h.
double cUnitConverter::offset [protected] |
the conversion offset from internal to external units
Definition at line 195 of file unit_converter.h.
char const* cUnitConverter::symbol [protected] |
the symbol of the external unit (something like "deg" or "ms")
Definition at line 189 of file unit_converter.h.