Interface to units.
#include <AlUnits.h>
class AlUnits
enum Type
{
kUnit, kSubunit, kPosition
};
enum LinearUnit
{
kMiles, kYards, kFeet, kInches,
kCentimeters, kMeters, kKilometers, kMillimeters
};
enum AngularUnit
{
kRadians, kDegrees, kMinutes, kSeconds
};
static AngularUnit angularUnits( Type type );
static double angularScale( Type type );
static LinearUnit linearUnits( Type type );
static double linearScale( Type type );
static double linearInCM( LinearUnit unit );
static double angularInDegrees( AngularUnit unit );
static statusCode parseStringAngular( const char* string, char* &ret, const char* format=0 );
static statusCode parseStringLinear( const char* string, char* &ret, const char* format=0 );
static statusCode parseStringNoUnits( const char* string, char* &ret, const char* format=0 );
This class provides access to linear and angular units in the Alias API. Note that all of the internal geometry routines work in centimeters and degrees. If you wish to use other units for distance tolerances and lengths, they must be converted to centimeters. Similarly, all angles must be converted to degrees.
statusCode AlUnits::parseStringAngular( const char* string, char* &ret, const char* format )
Parses a string and converts the resulting angle into degrees. An input string is a collection of angles separated by spaces or comma. An angle is composed of digits, units and ’:’ separators used to denote subunits. An angle does not contain any spaces.
For example, the string ’10deg:5.4min’ is converted to degrees (10.09 degrees) and the resulting value is placed into the return string as ’10.090000000 ’.
Strings such as ’10 deg:5.4min’ or ’10 deg, 5.4min’ and so on, are not considered to be valid for a single angle value.
If the format string is not specified, then the default format string ’%f’ is used (this reads a single angle). The format string uses a simplified version of the typical ’printf’ style arguments. To read three angles, specify format string of ’%f %f %f’. In the input string, spaces and commas ("," or " ") are used to separate the input items.
For example, if the format string is "%f %f", then the input string should be formatted as two angles separated by a space (for example, "10deg:5.4min 99sec"). The angles will be converted to degrees (10.09 degrees and 0.0275 degrees) and formatted into the return string separated by a space (for example, "10.09000000 0.027500000").
Note that the returned string contains the angle without any units in its string.
This function is available only under OpenAlias.
statusCode AlUnits::parseStringLinear( const char* string, char* &ret, const char* format )
statusCode AlUnits::parseStringNoUnits( const char* string, char* &ret, const char* format )