AlUnits
 
 
 

Interface to units.

Synopsis

#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 );

Description

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.

AlUnits::AngularUnit AlUnits::angularUnits( AlUnits::Type type )

Description

Returns the current angular units.

AlUnits::LinearUnit AlUnits::linearUnits( AlUnits::Type type )

Description

Returns the current linear units.

double AlUnits::angularScale( AlUnits::Type type )

Description

Returns the current scaling of the angular units.

double AlUnits::linearScale( AlUnits::Type type )

Description

Returns the current scaling of the linear units.

double AlUnits::linearInCM( AlUnits::LinearUnit unit )

Description

Returns the size of a unit in centimeters.

To convert a measurement to centimeters, use the equation:

double scale = AlUnits::linearScale( type );
double unitsInCM = AlUnits::linearInCM( type );
sizeCM = sizeInUnits * unitsInCM * scale;

Arguments

unit - the linear unit in question

double AlUnits::angularInDegrees( AlUnits::AngularUnit unit )

Description

Returns the size of a unit in degrees.

Arguments

unit - the angular unit in question

statusCode AlUnits::parseStringAngular( const char* string, char* &ret, const char* format )

Description

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.

Arguments

string - input string

ret - returned parsed string format - if this is not NULL, then it specifies the input format. ’%f’ is the default.

Return Codes

sSuccess - operation was successful

sFailure - format error

statusCode AlUnits::parseStringLinear( const char* string, char* &ret, const char* format )

Description

Parses a string and combines all of the units into a single unit. The result is converted to centimeters for linear units. See parseStringAngular for details. This function is available only under OpenAlias.

Arguments

string - input string

ret - returned parsed string

format - the input format

Return Codes

sSuccess - operation was successful

sFailure - format error

statusCode AlUnits::parseStringNoUnits( const char* string, char* &ret, const char* format )

Description

Parses a string and ’sprintfs’ the value into the resulting string. This method parses the string to ensure that it does not contain any units. This function is available only under OpenAlias.

Arguments

string - input string

ret - returned parsed string

format - the input format

Return Codes

sSuccess - operation was successful

sFailure - format error