Search Grid
AUVSI Search Path Algorithm 2019-2021
Macros | Enumerations | Functions | Variables
Conversions.cpp File Reference

Provides functions for converting GPS coordinates to and from 2D coordinates. Converts coordinates to 2D points on the plane tangent to the Earth approximated as a sphere at the anchor coordinate. More...

#include "Polygon.cpp"
#include <vector>

Macros

#define EARTH_RADIUS   6378137
 

Enumerations

enum  { X = 0, Y = 1, Z = 2 }
 Indeces used to store X, Y, and Z coordinates in a vector.
 

Functions

void init (float_type longitude, float_type latitude)
 Initialize global reference vectors used for basis vector conversion from an anchor coordinate. Call this before anything else. More...
 
std::vector< float_typeGPStoCartesian (const float_type longitude, const float_type latitude)
 Converts GPS longitude and latitude to 3D Cartesian coordinates with standard basis vectors. Origin is at the center of the Earth. More...
 
Coord GPStoCoord (const float_type longitude, const float_type latitude)
 Converts GPS longitude and latitude to 2D Cartesian coordinates measured in meters. More...
 
void CoordtoGPS (const Coord &c, float_type &longitude, float_type &latitude)
 Converts a 2D coordinate back to GPS longitude and latitude. More...
 
void computeBasis ()
 Compute the basis vectors for our Cartesian system. Make sure this is run after init at the start of main. More...
 
float_type toRadians (float_type degrees)
 Convert degrees to radians. More...
 
float_type toDegrees (float_type radians)
 Convert radians to degrees. More...
 
float_type toMeters (float_type feet)
 Convert feet to meters. More...
 
float_type toFeet (float_type meters)
 Convert meters to feet. More...
 
std::vector< float_typeconv::ourX (3)
 Basis vectors for our cartesian system.
 
std::vector< float_typeconv::ourY (3)
 
std::vector< float_typeconv::ourZ (3)
 

Variables

std::vector< float_typeconv::refCart
 GPS reference point in standard basis 3D Cartesian coordinates.
 
float_type conv::convMatrix [3][3] = {}
 Conversion matrix from standard basis to our basis.
 
float_type conv::REF_LONG = 0
 Longitude of GPS coordinate used as the origin of our Cartesian system in radians.
 
float_type conv::REF_LAT = 0
 Latitude of GPS coordinate used as the origin of our Cartesian system in radians.
 

Detailed Description

Provides functions for converting GPS coordinates to and from 2D coordinates. Converts coordinates to 2D points on the plane tangent to the Earth approximated as a sphere at the anchor coordinate.

Author
Harvey Lin

Function Documentation

◆ computeBasis()

void computeBasis ( )
inline

Compute the basis vectors for our Cartesian system. Make sure this is run after init at the start of main.

See also
init

◆ CoordtoGPS()

void CoordtoGPS ( const Coord c,
float_type longitude,
float_type latitude 
)

Converts a 2D coordinate back to GPS longitude and latitude.

Parameters
ccoordinate to convert
longitudestores the resulting longitude
latitudestores the resulting latitude
Returns
resulting longitude is stored in longitude, latitude is stored in latitude

◆ GPStoCartesian()

std::vector< float_type > GPStoCartesian ( const float_type  longitude,
const float_type  latitude 
)

Converts GPS longitude and latitude to 3D Cartesian coordinates with standard basis vectors. Origin is at the center of the Earth.

Parameters
longitudethe longitude of the coordinate in radians
latitudethe latitude of the coordinate in radians

◆ GPStoCoord()

Coord GPStoCoord ( const float_type  longitude,
const float_type  latitude 
)

Converts GPS longitude and latitude to 2D Cartesian coordinates measured in meters.

Parameters
longitudethe longitude of the coordinate in radians
latitudethe latitude of the coordinate in radians
Returns
equivalent 2D coordinate
See also
Coord

◆ init()

void init ( float_type  longitude,
float_type  latitude 
)

Initialize global reference vectors used for basis vector conversion from an anchor coordinate. Call this before anything else.

Parameters
longitudethe longitude of the anchor coordinate in radians
latitudethe latitude of the anchor coordinate in radians

◆ toDegrees()

float_type toDegrees ( float_type  radians)
inline

Convert radians to degrees.

Parameters
radiansradians to convert
Returns
requivalent in degrees
See also
float_type

◆ toFeet()

float_type toFeet ( float_type  meters)
inline

Convert meters to feet.

Parameters
metersmeters to convert
Returns
equivalent in feet
See also
float_type

◆ toMeters()

float_type toMeters ( float_type  feet)
inline

Convert feet to meters.

Parameters
feetfeet to convert
Returns
equivalent in meters
See also
float_type

◆ toRadians()

float_type toRadians ( float_type  degrees)
inline

Convert degrees to radians.

Parameters
degreesdegrees to convert
Returns
equivalent in radians
See also
float_type