GeoTessCPP  2.2
Software to facilitate storage and retrieval of 3D information about the Earth.
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
geotess::GeoTessUtils Class Reference

Collection of static functions to manipulate geographic information. More...

#include <GeoTessUtils.h>

Public Member Functions

 GeoTessUtils ()
 Default constructor. More...
 
virtual ~GeoTessUtils ()
 Destructor. More...
 
virtual int class_size () const
 Returns the class size. More...
 

Static Public Member Functions

static double angle (const double *const v0, const double *const v1)
 Return the angular distance in radians between two unit vectors. More...
 
static double angleDegrees (const double *const v0, const double *const v1)
 Return the angular distance in degrees between two unit vectors. More...
 
static double azimuth (const double *const v1, const double *const v2, double errorValue)
 Find the azimuth from unit vectors v1 to v2. More...
 
static double azimuthDegrees (const double *const v1, const double *const v2, double errorValue)
 Find the azimuth from unit vectors v1 to v2. More...
 
static double * center (double const *const *const v, int n)
 Return the normalized vector sum of the supplied unit vectors. More...
 
static void center (vector< double * > v, double *x)
 Return the normalized vector sum of the supplied unit vectors. More...
 
static void circumCenter (const double *const v0, const double *const v1, const double *const v2, double *const vs)
 Given three unit vectors, v0, v1 and v2, find the circumcenter, vs. More...
 
static void circumCenterPlus (const double *const v0, const double *const v1, const double *const v2, double *const vs)
 Given three unit vectors, v0, v1 and v2, find the circumcenter, vs. More...
 
static double * circumCenterPlus (const double *const v0, const double *const v1, const double *const v2)
 Given three unit vectors, v0, v1 and v2, find the circumcenter, vs. More...
 
static void circumCenterPlus (double const *const *const t, double *const vs)
 Given the three unit vectors, t[0], t[1] and t[2], find the circumcenter, vs. More...
 
static string class_name ()
 Returns the class name. More...
 
static void cross (const double *const v1, const double *const v2, double *const rslt)
 Cross product of two 3-component vectors. More...
 
static double * crossNormal (const double *const u, const double *const v)
 Normalized cross product of two 3-component unit vectors. More...
 
static double crossNormal (const double *const u, const double *const v, double *const w)
 Normalized cross product of two 3-component unit vectors. More...
 
static double crossNorth (const double *const u, double *const w)
 Normalized cross product of a 3-component unit vector with the north pole. More...
 
static double dot (const double *const v0, const double *const v1)
 Return the dot product of two vectors. More...
 
static double getDistance3D (const double *const v0, double r0, const double *const v1, double r1)
 Given two unit vectors and their radii, return the straight line separation between their tips. More...
 
static double getEarthRadius (const double *const v)
 Retrieve the radius of the Earth in km at the position specified by an Earth-centered unit vector. More...
 
static double getGeocentricLat (const double &lat)
 Return geocentric latitude given a geographic latitude using the WGS84 ellipsoid. More...
 
static double getGeographicLat (const double &lat)
 Return geographic latitude given a geocentric latitude using the WGS84 ellipsoid. More...
 
static double ** getGreatCircle (const double *const v0, const double *const v1)
 A great circle is defined by two unit vectors that are 90 degrees apart. More...
 
static void getGreatCircle (const double *const v0, const double *const v1, double **const gc)
 A great circle is defined by two unit vectors that are 90 degrees apart. More...
 
static double ** getGreatCircle (const double *const v, double azimuth)
 A great circle is defined by two unit vectors that are 90 degrees apart. More...
 
static void getGreatCircle (const double *const v, double azimuth, double **const gc)
 A great circle is defined by two unit vectors that are 90 degrees apart. More...
 
static double * getGreatCirclePoint (double const *const *const greatCircle, double distance)
 A great circle is defined by two unit vectors that are 90 degrees apart. More...
 
static void getGreatCirclePoint (double const *const *const greatCircle, double distance, double *const v)
 A great circle is defined by two unit vectors that are 90 degrees apart. More...
 
static int getGreatCirclePoints (double *ptA, double *ptB, const double &delta, const bool &onCenters)
 Retrieve the number of points that would be required to populate a great circle path from point A to point B with equally spaced points given that the spacing can be no greater than delta. More...
 
static double getGreatCirclePoints (double *ptA, double *ptB, const int &npoints, const bool &onCenters, double **points)
 Retrieve the unit vectors of a bunch of points distributed along a great circle path between two points. More...
 
static double getGreatCirclePoints (double *ptA, double *ptB, const double &delta, const bool &onCenters, double **points, int &npoints)
 Retrieve the unit vectors of a bunch of points distributed along a great circle path between two points. More...
 
static double getLat (const double *const v)
 Convert a 3-component unit vector to geographic latitude, in radians. More...
 
static double getLatDegrees (const double *const v)
 Convert a 3-component unit vector to geographic latitude, in degrees. More...
 
static string getLatLonString (const double *const v)
 
static double getLon (const double *const v)
 Convert a 3-component unit vector to a longitude, in radians. More...
 
static double getLonDegrees (const double *const v)
 Convert a 3-component unit vector to a longitude, in degrees. More...
 
static string getLonLatString (const double *const v)
 
static void getTransform (const double *const u, const double *const v, double **const t)
 Transform is a 3 x 3 matrix such that when a vector is multiplied by transform, the vector will be projected onto the plane of this GreatCircle. More...
 
static double getTriangleArea (const double *const v0, const double *const v1, const double *const v2)
 
static double getTriangleArea (const double *const v0, const double *const v1, const double *const v2, double *work1, double *work2, double *work3)
 
static double * getVector (const double &lat, const double &lon)
 Convert geographic lat, lon into a geocentric unit vector. More...
 
static double * getVector (const double &lat, const double &lon, double *v)
 Convert geographic lat, lon into a geocentric unit vector. More...
 
static double * getVectorDegrees (const double &lat, const double &lon)
 Convert geographic lat, lon into a geocentric unit vector. More...
 
static double * getVectorDegrees (const double &lat, const double &lon, double *v)
 Convert geographic lat, lon into a geocentric unit vector. More...
 
static string getVersion ()
 The current GeoTess version. More...
 
static bool isPole (const double *const u)
 Returns true if unit vector u is very close to [0, 0, +/- 1]. More...
 
static double length (const double *const u)
 Find the length of a 3-element vector. More...
 
static void move (const double *const w, const double *const vtp, double a, double *const u)
 Move unit vector w in direction of vtp by distance a and store result in u. More...
 
static bool moveDistAz (const double *const w, double distance, double azimuth, double *const u)
 Move unit vector w specified distance in direction given by azimuth and return the result in u. More...
 
static bool moveNorth (const double *const x, double distance, double *const z)
 Return a unit vector that is distance radians due north of positon x. More...
 
static double normalize (double *const u)
 Normalize the input vector to unit length. More...
 
static void normalizeFast (double *const u)
 Normalize the input vector to unit length. More...
 
static bool parallel (const double *const u, const double *const v)
 Returns true if unit vector u and v are parallel or very close to it. More...
 
static void readString (string &s, ifstream &ifs)
 Read a string from the input file stream and set into s. More...
 
static void rotate (const double *const x, const double *const p, double a, double *const z)
 Rotate unit vector x clockwise around unit vector p, by angle a. More...
 
static double scalarTripleProduct (const double *const v0, const double *const v1, const double *const v2)
 Calculate the scalar triple product of 3 3-component vectors: (v0 cross v1) dot v2. More...
 
static void transform (const double *x, double const *const *const t, double *const g)
 Project vector x onto the plane of a great circle. More...
 
static bool vectorTripleProduct (const double *const v0, const double *const v1, const double *const v2, double *const rslt)
 Compute the normalized vector triple product (v0 x v1) x v2 and store result in rslt. More...
 
static bool vectorTripleProductNorthPole (const double *const u, double *const w)
 Compute the normalized vector triple product (u x northPole) x u and store result in w. More...
 
static void writeString (ofstream &ofs, const string &s)
 Write the string s to the output file stream. More...
 

Static Public Attributes

static bool approximateLatitudes
 If true, then an approximate algorithm will be used to convert back and forth between geocentric and geographic latitudes. More...
 

Detailed Description

Collection of static functions to manipulate geographic information.

The Utils class provides basic static utility functions for GeoTess to manipulate geographic information.

Constructor & Destructor Documentation

geotess::GeoTessUtils::GeoTessUtils ( )
inline

Default constructor.

virtual geotess::GeoTessUtils::~GeoTessUtils ( )
inlinevirtual

Destructor.

Member Function Documentation

static double geotess::GeoTessUtils::angle ( const double *const  v0,
const double *const  v1 
)
inlinestatic

Return the angular distance in radians between two unit vectors.

Parameters
v0a 3 component unit vector
v1a 3 component unit vector
Returns
angular distance in radians.
static double geotess::GeoTessUtils::angleDegrees ( const double *const  v0,
const double *const  v1 
)
inlinestatic

Return the angular distance in degrees between two unit vectors.

Parameters
v0a 3 component unit vector
v1a 3 component unit vector
Returns
angular distance in degrees.
static double geotess::GeoTessUtils::azimuth ( const double *const  v1,
const double *const  v2,
double  errorValue 
)
static

Find the azimuth from unit vectors v1 to v2.

Result will be between -PI and PI radians.

Parameters
v1The point from which the azimuth will be directed toward v2.
v2The point to which the azimuth will be directed from v1.
errorValueif v1 and v2 are parallel, or if v1 is either the north or south pole, then return errorValue
Returns
the azimuth from v1 to v2, in radians clockwise from north, or errorValue
static double geotess::GeoTessUtils::azimuthDegrees ( const double *const  v1,
const double *const  v2,
double  errorValue 
)
static

Find the azimuth from unit vectors v1 to v2.

Result will be between -180 and 180 degrees

Parameters
v1The point from which the azimuth will be directed toward v2.
v2The point to which the azimuth will be directed from v1.
errorValueif v1 and v2 are parallel, or if v1 is either the north or south pole, then return errorValue
Returns
the azimuth from v1 to v2, in degrees clockwise from north, or errorValue
static double* geotess::GeoTessUtils::center ( double const *const *const  v,
int  n 
)
inlinestatic

Return the normalized vector sum of the supplied unit vectors.

Parameters
vone or more unit vectors
nsize of v
Returns
the normalized vector sum of the supplied unit vectors.
static void geotess::GeoTessUtils::center ( vector< double * >  v,
double *  x 
)
inlinestatic

Return the normalized vector sum of the supplied unit vectors.

Parameters
vone or more unit vectors
xthe 3-element array of double in which to place the computed unit vector.
static void geotess::GeoTessUtils::circumCenter ( const double *const  v0,
const double *const  v1,
const double *const  v2,
double *const  vs 
)
inlinestatic

Given three unit vectors, v0, v1 and v2, find the circumcenter, vs.

The circumcenter is the unit vector of the center of a small circle that has all three unit vectors on its circumference.

Parameters
v0
v1
v2
vs
static void geotess::GeoTessUtils::circumCenterPlus ( const double *const  v0,
const double *const  v1,
const double *const  v2,
double *const  vs 
)
inlinestatic

Given three unit vectors, v0, v1 and v2, find the circumcenter, vs.

The circumcenter is the unit vector of the center of a small circle that has all three unit vectors on its circumference. The fourth element of vs is the dot product of the new circumcenter with one of the vertices. In other words, cc[3] = cos(ccRadius).

Parameters
v0
v1
v2
vs
static double* geotess::GeoTessUtils::circumCenterPlus ( const double *const  v0,
const double *const  v1,
const double *const  v2 
)
inlinestatic

Given three unit vectors, v0, v1 and v2, find the circumcenter, vs.

The circumcenter is the unit vector of the center of a small circle that has all three unit vectors on its circumference. Vectors must be specified in clockwise order. The fourth element of returned circumcenter is the dot product of the new circumcenter with one of the vertices. In other words, cc[3] = cos(ccRadius).

Caller is responsible for deleting the double* returned by this method.

Parameters
v0
v1
v2
Returns
the circumCenter: a unit vector plus cos(ccRadius)
static void geotess::GeoTessUtils::circumCenterPlus ( double const *const *const  t,
double *const  vs 
)
inlinestatic

Given the three unit vectors, t[0], t[1] and t[2], find the circumcenter, vs.

The circumcenter is the unit vector of the center of a small circle that has all three unit vectors on its circumference. The fourth element of returned circumcenter is the dot product of the new circumcenter with one of the vertices. In other words, cc[3] = cos(ccRadius).

Parameters
ta 3 x 3 array of doubles that contains the three unit vectors of a triangle.
vsa 4 element array that will be populated with the unit vector and the cos(ccRadius).
Returns
true if successful, false if the three input vectors do not define a triangle.
static string geotess::GeoTessUtils::class_name ( )
inlinestatic

Returns the class name.

Returns
class name
virtual int geotess::GeoTessUtils::class_size ( ) const
inlinevirtual

Returns the class size.

Returns
class size
static void geotess::GeoTessUtils::cross ( const double *const  v1,
const double *const  v2,
double *const  rslt 
)
inlinestatic

Cross product of two 3-component vectors.

Result is not normalized.

Parameters
v1vector<double> vector one.
v2vector<double> vector two.
rsltset to v1 cross v2 Result is not a unit vector.
static double* geotess::GeoTessUtils::crossNormal ( const double *const  u,
const double *const  v 
)
inlinestatic

Normalized cross product of two 3-component unit vectors.

Parameters
uvector one.
vvector two.
Returns
Normalized cross product of u x v. Will be [0,0,0] if u and v are parallel.
static double geotess::GeoTessUtils::crossNormal ( const double *const  u,
const double *const  v,
double *const  w 
)
inlinestatic

Normalized cross product of two 3-component unit vectors.

Parameters
uvector one.
vvector two.
wset to u cross v, normalized to unit length. If u cross v has zero length, w will equal (0,0,0).
Returns
the length of u cross v prior to normalization. Guaranteed >= 0.
static double geotess::GeoTessUtils::crossNorth ( const double *const  u,
double *const  w 
)
inlinestatic

Normalized cross product of a 3-component unit vector with the north pole.

Parameters
uvector<double> vector one.
wset to u cross north, normalized to unit length. If u cross north has zero length, w will equal (0,0,0).
Returns
the length of u cross north prior to normalization. Guaranteed >= 0.
static double geotess::GeoTessUtils::dot ( const double *const  v0,
const double *const  v1 
)
inlinestatic

Return the dot product of two vectors.

Parameters
v0a 3 component vector
v1a 3 component vector
Returns
dot product
static double geotess::GeoTessUtils::getDistance3D ( const double *const  v0,
double  r0,
const double *const  v1,
double  r1 
)
inlinestatic

Given two unit vectors and their radii, return the straight line separation between their tips.

Assuming that the radii are in km, the result will also be in km.

Parameters
v0Point 0 unit vector.
r0Point 0 length (km).
v1Point 1 unit vector.
r1Point 1 length (km).
Returns
Distance between tip of v0*r0 and v1*r1, in km.
static double geotess::GeoTessUtils::getEarthRadius ( const double *const  v)
inlinestatic

Retrieve the radius of the Earth in km at the position specified by an Earth-centered unit vector.

Uses the WGS84 ellipsoid.

Parameters
vEarth-centered unit vector
Returns
radius of the Earth in km at specified position.
double geotess::GeoTessUtils::getGeocentricLat ( const double &  lat)
inlinestatic

Return geocentric latitude given a geographic latitude using the WGS84 ellipsoid.

Parameters
latgeographic latitude in radians
Returns
geocentric latitude in radians
double geotess::GeoTessUtils::getGeographicLat ( const double &  lat)
inlinestatic

Return geographic latitude given a geocentric latitude using the WGS84 ellipsoid.

Parameters
latgeocentric latitude in radians
Returns
geographic latitude in radians
static double** geotess::GeoTessUtils::getGreatCircle ( const double *const  v0,
const double *const  v1 
)
static

A great circle is defined by two unit vectors that are 90 degrees apart.

A great circle is stored in a double[2][3] array, which is the structure returned by this method. A great circle can be passed to the method getGreatCirclePoint() to retrieve a unit vector that is on the great circle and located some distance from the first point of the great circle.

This method returns a great circle that is computed from two unit vectors that are not necessarily 90 degrees apart.

Parameters
v0the first point on the great circle
v1some other point that is also on the great circle but which is not necessarily 90 degrees away from v0.
Returns
a 2 x 3 array specifying two unit vectors. The first one is a clone of unit vector v0 passed as first argument to this method. The second is located 90 degrees away from v0.
Exceptions
GeoTessExceptionif v0 and v1 are parallel.
static void geotess::GeoTessUtils::getGreatCircle ( const double *const  v0,
const double *const  v1,
double **const  gc 
)
static

A great circle is defined by two unit vectors that are 90 degrees apart.

A great circle is stored in a double[2][3] array, which is the structure returned by this method. A great circle can be passed to the method getGreatCirclePoint() to retrieve a unit vector that is on the great circle and located some distance from the first point of the great circle.

This method returns a great circle that is computed from two unit vectors that are not necessarily 90 degrees apart.

Parameters
v0the first point on the great circle
v1some other point that is also on the great circle but which is not necessarily 90 degrees away from v0.
gca 2 x 3 array specifying two unit vectors. The first one is a clone of unit vector v0 passed as first argument to this method. The second is located 90 degrees away from v0.
Exceptions
GeoTessExceptionif v0 and v1 are parallel.
static double** geotess::GeoTessUtils::getGreatCircle ( const double *const  v,
double  azimuth 
)
static

A great circle is defined by two unit vectors that are 90 degrees apart.

A great circle is stored in a double[2][3] array, which is the structure returned by this method. A great circle can be passed to the method getGreatCirclePoint() to retrieve a unit vector that is on the great circle and located some distance from the first point of the great circle.

This method returns a great circle that is defined by an initial point and an azimuth.

Parameters
va unit vector that will be the first point on the great circle.
azimutha direction, in radians, in which to move relative to v in order to define the great circle
Returns
a 2 x 3 array specifying two unit vectors. The first one is a clone of unit vector v passed as an argument to this method. The second is located 90 degrees away from v in the direction specified by azimuth.
Exceptions
GeoTessExceptionif v is located at north or south pole.
static void geotess::GeoTessUtils::getGreatCircle ( const double *const  v,
double  azimuth,
double **const  gc 
)
static

A great circle is defined by two unit vectors that are 90 degrees apart.

A great circle is stored in a double[2][3] array, which is the structure returned by this method. A great circle can be passed to the method getGreatCirclePoint() to retrieve a unit vector that is on the great circle and located some distance from the first point of the great circle.

This method returns a great circle that is defined by an initial point and an azimuth.

Parameters
va unit vector that will be the first point on the great circle.
azimutha direction, in radians, in which to move relative to v in order to define the great circle
gca 2 x 3 array specifying two unit vectors. The first one is a clone of unit vector v passed as an argument to this method. The second is located 90 degrees away from v in the direction specified by azimuth.
Exceptions
GeoTessExceptionif v is located at north or south pole.
static double* geotess::GeoTessUtils::getGreatCirclePoint ( double const *const *const  greatCircle,
double  distance 
)
inlinestatic

A great circle is defined by two unit vectors that are 90 degrees apart.

A great circle is stored in a double[2][3] array and one can be obtained by calling one of the getGreatCircle() methods.

In this method, a great circle and a distance are specified and a point is returned which is on the great circle path and is the specified distance away from the first point of the great circle.

Parameters
greatCirclea great circle structure
distancedistance in radians from first point of great circle
Returns
unit vector of point which is on great circle and located specified distance away from first point of great circle.
static void geotess::GeoTessUtils::getGreatCirclePoint ( double const *const *const  greatCircle,
double  distance,
double *const  v 
)
inlinestatic

A great circle is defined by two unit vectors that are 90 degrees apart.

A great circle is stored in a double[2][3] array and one can be obtained by calling one of the getGreatCircle() methods.

In this method, a great circle and a distance are specified and a point is returned which is on the great circle path and is the specified distance away from the first point of the great circle.

Parameters
greatCirclea great circle structure
distancedistance in radians from first point of great circle
vunit vector of point which is on great circle and located specified distance away from first point of great circle.
static int geotess::GeoTessUtils::getGreatCirclePoints ( double *  ptA,
double *  ptB,
const double &  delta,
const bool &  onCenters 
)
static

Retrieve the number of points that would be required to populate a great circle path from point A to point B with equally spaced points given that the spacing can be no greater than delta.

Parameters
ptAunit vector of first point on great circle (input)
ptBunit vector of last point on great circle (input)
deltadesired point spacing in radians (input)
onCentersif true, returned points will be located in the centers of equal size path increments. If false, first point will coincide with ptA, last point will coincide with ptB and the remaining points will be equally spaced in between. (input)
Returns
number of points required
static double geotess::GeoTessUtils::getGreatCirclePoints ( double *  ptA,
double *  ptB,
const int &  npoints,
const bool &  onCenters,
double **  points 
)
static

Retrieve the unit vectors of a bunch of points distributed along a great circle path between two points.

Parameters
ptAunit vector of first point on great circle (input)
ptBunit vector of last point on great circle (input)
npointsthe number of points to distribute along the great circle path (input)
onCentersif true, returned points will be located in the centers of equal size path increments. If false, first point will coincide with ptA, last point will coincide with ptB and the remaining points will be equally spaced in between. (input)
pointsan npoints by 3 array that will be populated with computed points. Must be large enough to hold all the computed points.
Returns
actual point spacing in radians
static double geotess::GeoTessUtils::getGreatCirclePoints ( double *  ptA,
double *  ptB,
const double &  delta,
const bool &  onCenters,
double **  points,
int &  npoints 
)
static

Retrieve the unit vectors of a bunch of points distributed along a great circle path between two points.

Caller specifies desired spacing of the points, not the number of points. The acutal spacing will generally be somewhat less than the request spacing in order that an integral number of points can be equally spaced along the path.

Parameters
ptAunit vector of first point on great circle (input)
ptBunit vector of last point on great circle (input)
deltadesired point spacing in radians (input)
onCentersif true, returned points will be located in the centers of equal size path increments. If false, first point will coincide with ptA, last point will coincide with ptB and the remaining points will be equally spaced in between. (input)
pointsan npoints by 3 array that will be populated with computed points. Must be large enough to hold all the computed points.
npointsthe number of points being returned.
Returns
actual point spacing in radians
static double geotess::GeoTessUtils::getLat ( const double *const  v)
inlinestatic

Convert a 3-component unit vector to geographic latitude, in radians.

Uses the WGS84 ellipsoid.

Parameters
v3-component unit vector
Returns
geographic latitude in radians.
static double geotess::GeoTessUtils::getLatDegrees ( const double *const  v)
inlinestatic

Convert a 3-component unit vector to geographic latitude, in degrees.

Uses the WGS84 ellipsoid.

Parameters
v3-component unit vector
Returns
geographic latitude in degrees.
static string geotess::GeoTessUtils::getLatLonString ( const double *const  v)
static
Parameters
vunit vector to be converted to lat, lon string
Returns
a String of lat,lon in degrees formatted with "%10.6f %11.6f"
static double geotess::GeoTessUtils::getLon ( const double *const  v)
inlinestatic

Convert a 3-component unit vector to a longitude, in radians.

Parameters
v3 component unit vector
Returns
longitude in radians.
static double geotess::GeoTessUtils::getLonDegrees ( const double *const  v)
inlinestatic

Convert a 3-component unit vector to a longitude, in degrees.

Parameters
v3 component unit vector
Returns
longitude in degrees.
static string geotess::GeoTessUtils::getLonLatString ( const double *const  v)
static
Parameters
vunit vector to be converted to lon,lat string
Returns
a String of lon,lat in degrees formatted with "%11.6f %10.6f"
static void geotess::GeoTessUtils::getTransform ( const double *const  u,
const double *const  v,
double **const  t 
)
static

Transform is a 3 x 3 matrix such that when a vector is multiplied by transform, the vector will be projected onto the plane of this GreatCircle.

The z direction will point out of the plane of the great circle in the direction of the observer (lastPoint cross firstPoint; parallel to normal). The y direction will correspond to the mean of firstPoint and lastPoint. The x direction will correspond to y cross z, forming a right handed coordinate system.

Parameters
ua 3-component unit vector defining start of great circle
va 3-component unit vector defining end of great circle
t3 x 3 array that will be populated with the transform
static double geotess::GeoTessUtils::getTriangleArea ( const double *const  v0,
const double *const  v1,
const double *const  v2 
)
inlinestatic
Parameters
v0first corner of triangle
v1second corner of triangle
v2third corner of triangle
Returns
the area of a triangle defined by three 3-component vectors
static double geotess::GeoTessUtils::getTriangleArea ( const double *const  v0,
const double *const  v1,
const double *const  v2,
double *  work1,
double *  work2,
double *  work3 
)
inlinestatic
Parameters
v0first corner of triangle
v1second corner of triangle
v2third corner of triangle
work1a double[3] used as work space
work2a double[3] used as work space
work3a double[3] used as work space
Returns
the area of a triangle defined by three 3-component vectors
static double* geotess::GeoTessUtils::getVector ( const double &  lat,
const double &  lon 
)
inlinestatic

Convert geographic lat, lon into a geocentric unit vector.

The x-component points toward lat,lon = 0, 0. The y-component points toward lat,lon = 0, PI/2. The z-component points toward north pole. Uses the WGS84 ellipsoid.

Parameters
latgeographic latitude in radians.
lonlongitude in radians.
Returns
3 component unit vector.
static double* geotess::GeoTessUtils::getVector ( const double &  lat,
const double &  lon,
double *  v 
)
inlinestatic

Convert geographic lat, lon into a geocentric unit vector.

The x-component points toward lat,lon = 0, 0. The y-component points toward lat,lon = 0, PI/2 The z-component points toward north pole. Uses the WGS84 ellipsoid.

Parameters
latgeographic latitude in radians.
lonlongitude in radians.
v3-component unit vector.
Returns
a pointer to v
static double* geotess::GeoTessUtils::getVectorDegrees ( const double &  lat,
const double &  lon 
)
inlinestatic

Convert geographic lat, lon into a geocentric unit vector.

The x-component points toward lat,lon = 0, 0. The y-component points toward lat,lon = 0, 90. The z-component points toward north pole. Uses the WGS84 ellipsoid.

Parameters
latgeographic latitude in degrees.
lonlongitude in degrees.
Returns
3 component unit vector.
static double* geotess::GeoTessUtils::getVectorDegrees ( const double &  lat,
const double &  lon,
double *  v 
)
inlinestatic

Convert geographic lat, lon into a geocentric unit vector.

The x-component points toward lat,lon = 0, 0. The y-component points toward lat,lon = 0, 90. The z-component points toward north pole. Uses the WGS84 ellipsoid.

Parameters
latgeographic latitude in degrees.
lonlongitude in degrees.
v3 component unit vector.
Returns
pointer to v
static string geotess::GeoTessUtils::getVersion ( )
inlinestatic

The current GeoTess version.

Returns
the current GeoTess version
static bool geotess::GeoTessUtils::isPole ( const double *const  u)
inlinestatic

Returns true if unit vector u is very close to [0, 0, +/- 1].

Parameters
uunit vector
Returns
true if unit vector u is very close to [0, 0, +/- 1]
static double geotess::GeoTessUtils::length ( const double *const  u)
inlinestatic

Find the length of a 3-element vector.

Parameters
udouble[]
Returns
the length of the vector. Guaranteed to be >= 0.
static void geotess::GeoTessUtils::move ( const double *const  w,
const double *const  vtp,
double  a,
double *const  u 
)
inlinestatic

Move unit vector w in direction of vtp by distance a and store result in u.

vtp is assumed to be a unit vector normal to w on input.

Parameters
wdouble[]
vtpdouble[]
adouble
udouble[]
static bool geotess::GeoTessUtils::moveDistAz ( const double *const  w,
double  distance,
double  azimuth,
double *const  u 
)
inlinestatic

Move unit vector w specified distance in direction given by azimuth and return the result in u.

If w is north or south pole, u will be equal to the same pole and method returns false.

Parameters
wdouble[] unit vector of starting position
distancedistance to move in radians
azimuthdirection to move in radians
udouble[] unit vector of resulting position.
Returns
true if successful, false if w is north or south pole
static bool geotess::GeoTessUtils::moveNorth ( const double *const  x,
double  distance,
double *const  z 
)
inlinestatic

Return a unit vector that is distance radians due north of positon x.

If x is the north or south pole, then z is set equal to x.

Parameters
xthe position to be moved.
distancethe distance, in radians, that x is to be moved toward the north.
zthe 3-element unit vector representing the position after having moved distance north.
Returns
true if operation successful, false if x is north or south pole.
static double geotess::GeoTessUtils::normalize ( double *const  u)
inlinestatic

Normalize the input vector to unit length.

Returns the length of the vector prior to normalization.

Parameters
uvector<double>
Returns
length of the vector prior to normalization ( >= 0.)
static void geotess::GeoTessUtils::normalizeFast ( double *const  u)
inlinestatic

Normalize the input vector to unit length.

Unlike normalize(), this method does not check to ensure that the length of the input vector is not zero. Only call this version if certain that the length of the vector is > 0.

Parameters
uvector<double>
static bool geotess::GeoTessUtils::parallel ( const double *const  u,
const double *const  v 
)
inlinestatic

Returns true if unit vector u and v are parallel or very close to it.

Parameters
ua unit vector
vanother unit vector
Returns
1.-abs(dot(u,v)) < 2e-15
static void geotess::GeoTessUtils::readString ( string &  s,
ifstream &  ifs 
)
inlinestatic

Read a string from the input file stream and set into s.

Parameters
sthe string that will be populated with results
ifsinput stream
static void geotess::GeoTessUtils::rotate ( const double *const  x,
const double *const  p,
double  a,
double *const  z 
)
static

Rotate unit vector x clockwise around unit vector p, by angle a.

x and z may be references to the same array. Clockwise rotation as viewed from outside the unit sphere is positive.

Parameters
xvector to be rotated
ppole about which rotation is to occur.
adouble the amount of rotation, in radians.
zthe rotated vector, normalized to unit length.
static double geotess::GeoTessUtils::scalarTripleProduct ( const double *const  v0,
const double *const  v1,
const double *const  v2 
)
inlinestatic

Calculate the scalar triple product of 3 3-component vectors: (v0 cross v1) dot v2.

Parameters
v0double[]
v1double[]
v2double[]
Returns
scalar triple product (v0 cross v1) dot v2
static void geotess::GeoTessUtils::transform ( const double *  x,
double const *const *const  t,
double *const  g 
)
inlinestatic

Project vector x onto the plane of a great circle.

Consider a great circle defined by two unti vectors, u and v. Find the transform of x by calling t = getTransform(u, v). Then call this method: transform(x, t, g), which will calculate unit vector g such that

  • g[2] is the z direction, i.e., the component of x that points out of the plane of the great circle, toward the observer (v cross u).
  • g[1] is the y direction, i.e., the mean of u and v, and
  • g[0] is the x direction, i.e, g[1] cross g2.
Parameters
xunit vector to be transformed
ttransform obtained with call to getTransform()
gtransformed unit vector
static bool geotess::GeoTessUtils::vectorTripleProduct ( const double *const  v0,
const double *const  v1,
const double *const  v2,
double *const  rslt 
)
inlinestatic

Compute the normalized vector triple product (v0 x v1) x v2 and store result in rslt.

It is ok if rslt is a reference to one of the input vectors. Local variables are used to ensure memory is not corrupted.

Parameters
v0double[]
v1double[]
v2double[]
rsltdouble[]
Returns
true if rslt has finite length, false if length(rslt) is zero.
static bool geotess::GeoTessUtils::vectorTripleProductNorthPole ( const double *const  u,
double *const  w 
)
inlinestatic

Compute the normalized vector triple product (u x northPole) x u and store result in w.

Returns false is u is north or south pole.

Parameters
udouble[]
wdouble[]
Returns
true if w has finite length, false if length(w) is zero.
static void geotess::GeoTessUtils::writeString ( ofstream &  ofs,
const string &  s 
)
inlinestatic

Write the string s to the output file stream.

Parameters
ofsoutput stream
sthe string to write the output stream.

Member Data Documentation

bool geotess::GeoTessUtils::approximateLatitudes
static

If true, then an approximate algorithm will be used to convert back and forth between geocentric and geographic latitudes.

The approximation incurs an error of about 0.1 meters in latitude calculations but is faster than the correct calculation.

Note that the existence of this static, mutable variable technically violates thread-safety of this class. But given the assumption that the approximation is just as good as the true conversions, this is not a significant violation.


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