SDHLibrary-CPP 0.0.2.10SCHUNK GmbH & Co. KG
C++ access library for SCHUNK Dextrous Hand SDH

SDH::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)
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
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")
char const * GetSymbol (void) const
 Return the symbol of the external unit (something like "deg" or "ms")
double GetFactor (void) const
 Return the conversion factor from internal to external units.
double GetOffset (void) const
 Return the conversion offset from internal to external units.
int GetDecimalPlaces (void) const
 Return the number of decimal places for printing values in the external unit system.

Protected Attributes

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")
char const * symbol
 the symbol of the external unit (something like "deg" or "ms")
double factor
 the conversion factor from internal to external units
double offset
 the conversion offset from internal to external units
int decimal_places
 A usefull number of decimal places for printing values in the external unit system.

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.



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

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

cSimpleVector cUnitConverter::ToExternal ( cSimpleVector internal) const

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.

double cUnitConverter::ToExternal ( double  internal) const

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

double cUnitConverter::ToInternal ( double  external) const

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

cSimpleVector cUnitConverter::ToInternal ( cSimpleVector external) const

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.

double SDH::cUnitConverter::factor [protected]

the conversion factor from internal to external units

char const* SDH::cUnitConverter::kind [protected]

the kind of unit to be converted (something like "angle" or "time")

char const* SDH::cUnitConverter::name [protected]

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

double SDH::cUnitConverter::offset [protected]

the conversion offset from internal to external units

char const* SDH::cUnitConverter::symbol [protected]

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


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