VR-Link API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
13.3 - Coordinate Conversions

Table of Contents

VR-Link supports several coordinate systems and provides classes and functions for converting locations, vectors, and orientations from one system to another.

13.3.1 Geocentric Coordinates

DIS and the RPR FOM in HLA specify that world locations, velocities, accelerations and orientations be represented with respect to a right-hand geocentric Cartesian coordinate system. The origin of this geocentric coordinate system is the center of the earth. The positive X-axis passes through the prime meridian at the equator; the positive Y-axis passes through 90 degrees east longitude at the equator; and the positive Z-axis passes though the north pole (as illustrated below.)

The DtVector class is typically used to represent locations and vectors in geocentric coordinates, while DtTaitBryan or DtDcm is used to represent orientation.

geocentriccoordinatesystem.png
Geocentric Coordinate System

13.3.2 Geodetic Coordinates

Geodetic coordinates are another means of specifying location in the world. VR-Link geodetic coordinates consist of latitude and longitude in radians, and altitude in meters above a certain reference ellipsoid, for example, the surface of the earth at sea level.

VR-Link uses the class DtGeodeticCoord (defined in geodeticCoord.h) to represent geodetic coordinates. A DtGeodeticCoord can be initialized from a latitude, longitude, and altitude. Negative latitudes are south latitudes; negative longitudes are west longitudes.

DtGeodeticCoord myLoc(DtDeg2Rad(45.0), DtDeg2Rad(30.0), 1000.0);

If the default constructor is used, the resulting object represents a latitude, longitude, and altitude of zero.

DtGeodeticCoord has the following inspectors and mutators to get and set values for the individual components of a geodetic coordinate:

DtGeodeticCoord also has member functions that enable you to convert to and from geocentric coordinates. DtGeodeticCoord::geocentric() returns the geocentric equivalent of a geodetic coordinate. For example:

DtGeodeticCoord geod(DtDeg2Rad(30.0), DtDeg2Rad(100.0), 1000.0);
DtVector geoc = geod.geocentric();

After these lines of code, geoc will contain the coordinate:

{-960122.075, 5445122.868, 3170873.735}

which represents the same point in space as 30 degrees north latitude, 100 degrees east longitude, 1000 meters altitude.

A similar function is DtGeodeticCoord::getGeocentric(), which, rather than returning a geocentric coordinate, sets the value of an existing DtVector, for example:

DtGeodeticCoord geod(DtDeg2Rad(30.0), DtDeg2Rad(100.0), 1000.0);
DtVector geoc;
geod.getGeocentric(geoc);

Going in the other direction, DtGeodeticCoord::setGeocentric() sets the value of a DtGeodeticCoord to the latitude/longitude/altitude equivalent of a given geocentric coordinate:

DtVector geoc(-960122.075, 5445122.868, 3170873.735);
geod.setGeocentric(geoc);

Also in geodeticCoord.h, are the C-style functions DtGeocToGeod() and DtGeocToGeod(), which you can use instead of the member functions described previously, to convert between geocentric and geodetic coordinates, although their use is discouraged in favor of the member functions.

13.3.2.1 Choosing a Reference Ellipsoid

The default reference ellipsoid used for geocentric to geodetic conversions is WGS84, but this is configurable through the function DtUseMapDatum(), declared in geodeticCoord.h. Any DtMapDatum can be passed to this function. DtMapDatum is defined as:

typedef struct DtSpheroid
{
DtFloat64 semiMajor; // semimajor axis of the ellipsoid, in meters
DtFloat64 semiMinor; // semiminor axis of the ellipsoid, in meters
typedef struct DtMapDatum
{
DtFloat64 datumShift[3]; // added to WGS84 to get GCC in this datum

VR-Link has the following DtMapDatums pre-defined in mapDatum.h: