Public Member Functions | Protected Attributes
cUnitConverter Class Reference

Unit conversion class to convert values between physical unit systems. More...

#include <unit_converter.h>

List of all members.

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")

Detailed Description

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 92 of file unit_converter.h.


Constructor & Destructor Documentation

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

Parameters:
_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
Attention:
The strings given _kind, _name and _symbol are NOT copied, just their address is stored

Member Function Documentation

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

Convert single value internal given in internal units into external units. Returns internal * factor + offset

Convert values in simple array internal, each given in internal units into external units. Returns a simple array with each valid element converted with internal[i] * factor + offset

Only valid entries of the internal vector are converted.

std::vector<double> cUnitConverter::ToExternal ( std::vector< double > const &  internal) const

Convert values in vector internal, each given in internal units into external units. Returns a vector with each element converted with internal[i] * factor + offset

double cUnitConverter::ToInternal ( double  external) const

Convert value external given in external units into internal units. Returns (external - offset) / factor

Convert values in simple array external, each given in external units into internal units. Returns a simple array with each valid element converted with external[i] * factor + offset

Only valid entries of the external vector are converted.

std::vector<double> cUnitConverter::ToInternal ( std::vector< double > const &  external) const

Convert values in vector external, each given in external units into internal units. Returns a vector with each valid element converted with external[i] * factor + offset


Member Data Documentation

A usefull number of decimal places for printing values in the external unit system.

Definition at line 215 of file unit_converter.h.

double cUnitConverter::factor [protected]

the conversion factor from internal to external units

Definition at line 209 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 200 of file unit_converter.h.

char const* cUnitConverter::name [protected]

the name of the external unit (something like "degrees" or "milliseconds")

Definition at line 203 of file unit_converter.h.

double cUnitConverter::offset [protected]

the conversion offset from internal to external units

Definition at line 212 of file unit_converter.h.

char const* cUnitConverter::symbol [protected]

the symbol of the external unit (something like "deg" or "ms")

Definition at line 206 of file unit_converter.h.


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


schunk_sdh
Author(s): Mathias Luedtke , Florian Weisshardt
autogenerated on Sat Jun 8 2019 20:25:21