GeoTessCPP
2.6.1
Software to facilitate storage and retrieval of 3D information about the Earth.
|
Collection of static functions to manipulate geographic information. More...
#include <GeoTessUtils.h>
Public Member Functions | |
GeoTessUtils () | |
virtual | ~GeoTessUtils () |
virtual int | class_size () const |
Static Public Member Functions | |
static string | class_name () |
static string | getVersion () |
static double | dot (const double *const v0, const double *const v1) |
static double | scalarTripleProduct (const double *const v0, const double *const v1, const double *const v2) |
static double | getGeocentricLat (const double &lat) |
static double | getGeographicLat (const double &lat) |
static string | getLatLonString (const double *const v) |
static string | getLonLatString (const double *const v) |
static double | azimuthDegrees (const double *const v1, const double *const v2, double errorValue) |
static double | azimuth (const double *const v1, const double *const v2, double errorValue) |
static void | rotate (const double *const x, const double *const p, double a, double *const z) |
static double ** | getGreatCircle (const double *const v0, const double *const v1) |
static void | getGreatCircle (const double *const v0, const double *const v1, double **const gc) |
static double ** | getGreatCircle (const double *const v, double azimuth) |
static void | getGreatCircle (const double *const v, double azimuth, double **const gc) |
static int | getGreatCirclePoints (double *ptA, double *ptB, const double &delta, const bool &onCenters) |
static double | getGreatCirclePoints (double *ptA, double *ptB, const int &npoints, const bool &onCenters, double **points) |
static double | getGreatCirclePoints (double *ptA, double *ptB, const double &delta, const bool &onCenters, double **points, int &npoints) |
static double | length (const double *const u) |
static void | getTransform (const double *const u, const double *const v, double **const t) |
static void | transform (const double *x, double const *const *const t, double *const g) |
static void | readString (string &s, ifstream &ifs) |
static void | writeString (ofstream &ofs, const string &s) |
static double | angle (const double *const v0, const double *const v1) |
static double | angleDegrees (const double *const v0, const double *const v1) |
static double | getDistance3D (const double *const v0, double r0, const double *const v1, double r1) |
static double | getEarthRadius (const double *const v) |
static double | getLat (const double *const v) |
static double | getLon (const double *const v) |
static double | getLatDegrees (const double *const v) |
static double | getLonDegrees (const double *const v) |
static double * | getVectorDegrees (const double &lat, const double &lon) |
static double * | getVectorDegrees (const double &lat, const double &lon, double *v) |
static double * | getVector (const double &lat, const double &lon) |
static double * | getVector (const double &lat, const double &lon, double *v) |
static void | normalizeFast (double *const u) |
static double | normalize (double *const u) |
static void | cross (const double *const v1, const double *const v2, double *const rslt) |
static double * | crossNormal (const double *const u, const double *const v) |
static double | crossNormal (const double *const u, const double *const v, double *const w) |
static double | crossNorth (const double *const u, double *const w) |
static bool | vectorTripleProduct (const double *const v0, const double *const v1, const double *const v2, double *const rslt) |
static bool | vectorTripleProductNorthPole (const double *const u, double *const w) |
static void | circumCenter (const double *const v0, const double *const v1, const double *const v2, double *const vs) |
static void | circumCenterPlus (const double *const v0, const double *const v1, const double *const v2, double *const vs) |
static double * | circumCenterPlus (const double *const v0, const double *const v1, const double *const v2) |
static void | circumCenterPlus (double const *const *const t, double *const vs) |
static bool | moveDistAz (const double *const w, double distance, double azimuth, double *const u) |
static void | move (const double *const w, const double *const vtp, double a, double *const u) |
static bool | moveNorth (const double *const x, double distance, double *const z) |
static bool | isPole (const double *const u) |
static bool | parallel (const double *const u, const double *const v) |
static double * | getGreatCirclePoint (double const *const *const greatCircle, double distance) |
static void | getGreatCirclePoint (double const *const *const greatCircle, double distance, double *const v) |
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 * | center (double const *const *const v, int n) |
static void | center (vector< double * > v, double *x) |
Static Public Attributes | |
static bool | approximateLatitudes |
Collection of static functions to manipulate geographic information.
The Utils class provides basic static utility functions for GeoTess to manipulate geographic information.
Definition at line 69 of file GeoTessUtils.h.
|
inline |
Default constructor.
Definition at line 100 of file GeoTessUtils.h.
|
inlinevirtual |
Destructor.
Definition at line 105 of file GeoTessUtils.h.
|
inlinestatic |
Return the angular distance in radians between two unit vectors.
v0 | a 3 component unit vector |
v1 | a 3 component unit vector |
Definition at line 497 of file GeoTessUtils.h.
|
inlinestatic |
Return the angular distance in degrees between two unit vectors.
v0 | a 3 component unit vector |
v1 | a 3 component unit vector |
Definition at line 515 of file GeoTessUtils.h.
|
static |
Find the azimuth from unit vectors v1 to v2. Result will be between -PI and PI radians.
v1 | The point from which the azimuth will be directed toward v2. |
v2 | The point to which the azimuth will be directed from v1. |
errorValue | if v1 and v2 are parallel, or if v1 is either the north or south pole, then return errorValue |
|
static |
Find the azimuth from unit vectors v1 to v2. Result will be between -180 and 180 degrees
v1 | The point from which the azimuth will be directed toward v2. |
v2 | The point to which the azimuth will be directed from v1. |
errorValue | if v1 and v2 are parallel, or if v1 is either the north or south pole, then return errorValue |
|
inlinestatic |
Return the normalized vector sum of the supplied unit vectors.
v | one or more unit vectors |
n | size of v |
Definition at line 1173 of file GeoTessUtils.h.
|
inlinestatic |
Return the normalized vector sum of the supplied unit vectors.
v | one or more unit vectors |
x | the 3-element array of double in which to place the computed unit vector. |
Definition at line 1197 of file GeoTessUtils.h.
|
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.
v0 | |
v1 | |
v2 | |
vs |
Definition at line 875 of file GeoTessUtils.h.
|
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.
v0 | |
v1 | |
v2 |
Definition at line 929 of file GeoTessUtils.h.
|
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).
v0 | |
v1 | |
v2 | |
vs |
Definition at line 900 of file GeoTessUtils.h.
|
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).
t | a 3 x 3 array of doubles that contains the three unit vectors of a triangle. |
vs | a 4 element array that will be populated with the unit vector and the cos(ccRadius). |
Definition at line 959 of file GeoTessUtils.h.
|
inlinestatic |
|
inlinevirtual |
|
inlinestatic |
Cross product of two 3-component vectors. Result is not normalized.
v1 | vector<double> vector one. |
v2 | vector<double> vector two. |
rslt | set to v1 cross v2 Result is not a unit vector. |
Definition at line 728 of file GeoTessUtils.h.
|
inlinestatic |
Normalized cross product of two 3-component unit vectors.
u | vector one. |
v | vector two. |
Definition at line 746 of file GeoTessUtils.h.
|
inlinestatic |
Normalized cross product of two 3-component unit vectors.
u | vector one. |
v | vector two. |
w | set to u cross v, normalized to unit length. If u cross v has zero length, w will equal (0,0,0). |
Definition at line 769 of file GeoTessUtils.h.
|
inlinestatic |
Normalized cross product of a 3-component unit vector with the north pole.
u | vector<double> vector one. |
w | set to u cross north, normalized to unit length. If u cross north has zero length, w will equal (0,0,0). |
Definition at line 790 of file GeoTessUtils.h.
|
inlinestatic |
Return the dot product of two vectors.
v0 | a 3 component vector |
v1 | a 3 component vector |
Definition at line 134 of file GeoTessUtils.h.
|
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.
v0 | Point 0 unit vector. |
r0 | Point 0 length (km). |
v1 | Point 1 unit vector. |
r1 | Point 1 length (km). |
Definition at line 537 of file GeoTessUtils.h.
|
inlinestatic |
Retrieve the radius of the Earth in km at the position specified by an Earth-centered unit vector. Uses the WGS84 ellipsoid.
v | Earth-centered unit vector |
Definition at line 553 of file GeoTessUtils.h.
|
inlinestatic |
Return geocentric latitude given a geographic latitude using the WGS84 ellipsoid
lat | geographic latitude in radians |
Definition at line 1761 of file GeoTessUtils.h.
|
inlinestatic |
Return geographic latitude given a geocentric latitude using the WGS84 ellipsoid
lat | geocentric latitude in radians |
Definition at line 1749 of file GeoTessUtils.h.
|
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.
v | a unit vector that will be the first point on the great circle. |
azimuth | a direction, in radians, in which to move relative to v in order to define the great circle |
GeoTessException | if v is located at north or south pole. |
|
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.
v | a unit vector that will be the first point on the great circle. |
azimuth | a direction, in radians, in which to move relative to v in order to define the great circle |
gc | 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. |
GeoTessException | if v is located at north or south pole. |
|
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.
v0 | the first point on the great circle |
v1 | some other point that is also on the great circle but which is not necessarily 90 degrees away from v0. |
GeoTessException | if v0 and v1 are parallel. |
|
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.
v0 | the first point on the great circle |
v1 | some other point that is also on the great circle but which is not necessarily 90 degrees away from v0. |
gc | 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. |
GeoTessException | if v0 and v1 are parallel. |
|
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.
greatCircle | a great circle structure |
distance | distance in radians from first point of great circle |
Definition at line 1087 of file GeoTessUtils.h.
|
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.
greatCircle | a great circle structure |
distance | distance in radians from first point of great circle |
v | unit vector of point which is on great circle and located specified distance away from first point of great circle. |
Definition at line 1112 of file GeoTessUtils.h.
|
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.
ptA | unit vector of first point on great circle (input) |
ptB | unit vector of last point on great circle (input) |
delta | desired point spacing in radians (input) |
onCenters | if 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) |
|
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.
ptA | unit vector of first point on great circle (input) |
ptB | unit vector of last point on great circle (input) |
delta | desired point spacing in radians (input) |
onCenters | if 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) |
points | an npoints by 3 array that will be populated with computed points. Must be large enough to hold all the computed points. |
npoints | the number of points being returned. |
|
static |
Retrieve the unit vectors of a bunch of points distributed along a great circle path between two points.
ptA | unit vector of first point on great circle (input) |
ptB | unit vector of last point on great circle (input) |
npoints | the number of points to distribute along the great circle path (input) |
onCenters | if 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) |
points | an npoints by 3 array that will be populated with computed points. Must be large enough to hold all the computed points. |
|
inlinestatic |
Convert a 3-component unit vector to geographic latitude, in radians. Uses the WGS84 ellipsoid.
v | 3-component unit vector |
Definition at line 563 of file GeoTessUtils.h.
|
inlinestatic |
Convert a 3-component unit vector to geographic latitude, in degrees. Uses the WGS84 ellipsoid.
v | 3-component unit vector |
Definition at line 582 of file GeoTessUtils.h.
|
static |
v | unit vector to be converted to lat, lon string |
|
inlinestatic |
Convert a 3-component unit vector to a longitude, in radians.
v | 3 component unit vector |
Definition at line 572 of file GeoTessUtils.h.
|
inlinestatic |
Convert a 3-component unit vector to a longitude, in degrees.
v | 3 component unit vector |
Definition at line 595 of file GeoTessUtils.h.
|
static |
v | unit vector to be converted to lon,lat string |
|
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.
u | a 3-component unit vector defining start of great circle |
v | a 3-component unit vector defining end of great circle |
t | 3 x 3 array that will be populated with the transform |
|
inlinestatic |
v0 | first corner of triangle |
v1 | second corner of triangle |
v2 | third corner of triangle |
Definition at line 1129 of file GeoTessUtils.h.
|
inlinestatic |
v0 | first corner of triangle |
v1 | second corner of triangle |
v2 | third corner of triangle |
work1 | a double[3] used as work space |
work2 | a double[3] used as work space |
work3 | a double[3] used as work space |
Definition at line 1148 of file GeoTessUtils.h.
|
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.
lat | geographic latitude in radians. |
lon | longitude in radians. |
Definition at line 641 of file GeoTessUtils.h.
|
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.
lat | geographic latitude in radians. |
lon | longitude in radians. |
v | 3-component unit vector. |
Definition at line 659 of file GeoTessUtils.h.
|
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.
lat | geographic latitude in degrees. |
lon | longitude in degrees. |
Definition at line 610 of file GeoTessUtils.h.
|
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.
lat | geographic latitude in degrees. |
lon | longitude in degrees. |
v | 3 component unit vector. |
Definition at line 625 of file GeoTessUtils.h.
|
inlinestatic |
The current GeoTess version.
Definition at line 125 of file GeoTessUtils.h.
|
inlinestatic |
Returns true if unit vector u is very close to [0, 0, +/- 1]
u | unit vector |
Definition at line 1052 of file GeoTessUtils.h.
|
inlinestatic |
Find the length of a 3-element vector.
u | double[] |
Definition at line 420 of file GeoTessUtils.h.
|
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.
w | double[] |
vtp | double[] |
a | double |
u | double[] |
Definition at line 1005 of file GeoTessUtils.h.
|
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.
w | double[] unit vector of starting position |
distance | distance to move in radians |
azimuth | direction to move in radians |
u | double[] unit vector of resulting position. |
Definition at line 977 of file GeoTessUtils.h.
|
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.
x | the position to be moved. |
distance | the distance, in radians, that x is to be moved toward the north. |
z | the 3-element unit vector representing the position after having moved distance north. |
Definition at line 1029 of file GeoTessUtils.h.
|
inlinestatic |
Normalize the input vector to unit length. Returns the length of the vector prior to normalization.
u | vector<double> |
Definition at line 701 of file GeoTessUtils.h.
|
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.
u | vector<double> |
Definition at line 685 of file GeoTessUtils.h.
|
inlinestatic |
Returns true if unit vector u and v are parallel or very close to it
u | a unit vector |
v | another unit vector |
Definition at line 1066 of file GeoTessUtils.h.
|
inlinestatic |
Read a string from the input file stream and set into s
s | the string that will be populated with results |
ifs | input stream |
Definition at line 469 of file GeoTessUtils.h.
|
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.
x | vector to be rotated |
p | pole about which rotation is to occur. |
a | double the amount of rotation, in radians. |
z | the rotated vector, normalized to unit length. |
|
inlinestatic |
Calculate the scalar triple product of 3 3-component vectors: (v0 cross v1) dot v2
v0 | double[] |
v1 | double[] |
v2 | double[] |
Definition at line 146 of file GeoTessUtils.h.
|
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
x | unit vector to be transformed |
t | transform obtained with call to getTransform() |
g | transformed unit vector |
Definition at line 456 of file GeoTessUtils.h.
|
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.
v0 | double[] |
v1 | double[] |
v2 | double[] |
rslt | double[] |
Definition at line 822 of file GeoTessUtils.h.
|
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.
u | double[] |
w | double[] |
Definition at line 856 of file GeoTessUtils.h.
|
inlinestatic |
Write the string s to the output file stream.
ofs | output stream |
s | the string to write the output stream. |
Definition at line 484 of file GeoTessUtils.h.
|
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.
Definition at line 95 of file GeoTessUtils.h.