46 #ifdef HAVE_LONG_DOUBLE 69 const double clat = cos(
DEG2RAD(in_coords_origin.
lat)),
71 const double clon = cos(
DEG2RAD(in_coords_origin.
lon)),
81 out_ENU_point.
x = -slon * P_geocentric.
x + clon * P_geocentric.
y;
82 out_ENU_point.
y = -clon * slat * P_geocentric.
x -
83 slon * slat * P_geocentric.
y + clat * P_geocentric.
z;
84 out_ENU_point.
z = clon * clat * P_geocentric.
x +
85 slon * clat * P_geocentric.
y + slat * P_geocentric.
z;
89 const std::vector<mrpt::math::TPoint3D>& in_geocentric_points,
90 std::vector<mrpt::math::TPoint3D>& out_ENU_points,
97 const double clat = cos(
DEG2RAD(in_coords_origin.
lat)),
99 const double clon = cos(
DEG2RAD(in_coords_origin.
lon)),
102 const size_t N = in_geocentric_points.size();
103 out_ENU_points.resize(N);
104 for (
size_t i = 0; i < N; i++)
108 in_geocentric_points[i] - P_geocentric_ref;
113 out_ENU_points[i].x = -slon * P_geocentric.
x + clon * P_geocentric.
y;
114 out_ENU_points[i].y = -clon * slat * P_geocentric.
x -
115 slon * slat * P_geocentric.
y +
116 clat * P_geocentric.
z;
117 out_ENU_points[i].z = clon * clat * P_geocentric.
x +
118 slon * clat * P_geocentric.
y +
119 slat * P_geocentric.
z;
151 double in_longitude_reference_degrees,
double in_latitude_reference_degrees,
159 in_latitude_reference_degrees, in_longitude_reference_degrees,
160 in_height_reference_meters),
163 const double clat = cos(
DEG2RAD(in_latitude_reference_degrees)),
164 slat = sin(
DEG2RAD(in_latitude_reference_degrees));
165 const double clon = cos(
DEG2RAD(in_longitude_reference_degrees)),
166 slon = sin(
DEG2RAD(in_longitude_reference_degrees));
170 HM(0, 1) = -clon * slat;
171 HM(0, 2) = clon * clat;
173 HM(1, 1) = -slon * slat;
174 HM(1, 2) = slon * clat;
222 out_point.
z = (cos2_ae_earth * N + in_coords.
height) * sin(
lat);
253 out_point.
z = (cos2_ae_earth * N + in_coords.
height) * sin(
lat);
263 const double sa2 = ellip.
sa * ellip.
sa;
264 const double sb2 = ellip.
sb * ellip.
sb;
266 const double e2 = (sa2 - sb2) / sa2;
267 const double ep2 = (sa2 - sb2) / sb2;
268 const double p = sqrt(in_point.
x * in_point.
x + in_point.
y * in_point.
y);
269 const double theta = atan2(in_point.
z * ellip.
sa,
p * ellip.
sb);
271 out_coords.
lon = atan2(in_point.
y, in_point.
x);
272 out_coords.
lat = atan2(
273 in_point.
z + ep2 * ellip.
sb * sin(theta) * sin(theta) * sin(theta),
274 p - e2 * ellip.
sa * cos(theta) * cos(theta) * cos(theta));
276 const double clat = cos(out_coords.
lat);
277 const double slat = sin(out_coords.
lat);
278 const double N = sa2 / sqrt(sa2 * clat * clat + sb2 * slat * slat);
280 out_coords.
height =
p / clat - N;
290 double X,
double Y,
int huso,
char hem,
double& out_lon ,
293 ASSERT_(hem ==
's' || hem ==
'S' || hem ==
'n' || hem ==
'N');
296 if (hem ==
's' || hem ==
'S') Y = Y - 1e7;
303 const precnum_t latp = Y / (6366197.724 * 0.9996);
306 const precnum_t v =
c * 0.9996 / sqrt(1 + ep2 * clp2);
311 const precnum_t J4 = 0.75 * J2 + 0.25 * A2;
312 const precnum_t J6 = (5 * J4 + A2 * clp2) / 3;
315 const precnum_t beta = (5.0 / 3.0) * alp * alp;
316 const precnum_t gam = (35.0 / 27.0) * alp * alp * alp;
317 const precnum_t B = 0.9996 *
c * (latp - alp * J2 + beta * J4 - gam * J6);
321 const precnum_t nu = nb * (1 - psi) + latp;
323 const precnum_t dlon = atan2(she, cos(nu));
324 const precnum_t tau = atan2(cos(dlon) * tan(nu), 1);
326 out_lon =
RAD2DEG(dlon) + lon0;
329 (1 + ep2 * clp2 - 1.5 * ep2 * sin(latp) * cos(latp) * (tau - latp)) *
335 char& UTMLatitudeBand,
const TEllipsoid& ellip)
337 const double la = GeodeticCoords.
lat;
382 const int Huso =
mrpt::fix((GeodeticCoords.
lon / 6) + 31);
388 const precnum_t ep2 = (sa * sa - sb * sb) / (sb * sb);
400 const precnum_t v = 0.9996 *
c / sqrt(1 + ep2 * clat * clat);
405 const precnum_t J4 = 0.75 * J2 + 0.25 * A2;
406 const precnum_t J6 = (5.0 * J4 + A2 * clat * clat) / 3;
408 const precnum_t nbet = (5.0 / 3.0) * nalp * nalp;
409 const precnum_t ngam = (35.0 / 27.0) * nalp * nalp * nalp;
410 const precnum_t B = 0.9996 *
c * (
lat - nalp * J2 + nbet * J4 - ngam * J6);
412 UTMCoords.
x =
eps *
v * (1 + psi / 3.0) + 500000;
413 UTMCoords.
y = nu *
v * (1 + psi) + B;
414 UTMCoords.
z = GeodeticCoords.
height;
417 UTMLatitudeBand = Letra;
424 double la,
double lo,
double& xx,
double& yy,
int& out_UTM_zone,
425 char& out_UTM_latitude_band,
const TEllipsoid& ellip)
431 const double sa = ellip.
sa;
432 const double sb = ellip.
sb;
433 const double e2 = (sqrt((sa * sa) - (sb * sb))) / sb;
435 const double e2cuadrada = e2 * e2;
437 const double c = (sa * sa) / sb;
442 const int Huso =
mrpt::fix((lo / 6) + 31);
443 double S = ((Huso * 6) - 183);
489 const double a = cos(
lat) * sin(deltaS);
490 const double epsilon = 0.5 * log((1 +
a) / (1 -
a));
491 const double nu = atan(tan(
lat) / cos(deltaS)) -
lat;
492 const double v = (
c / sqrt((1 + (e2cuadrada *
square(cos(
lat)))))) * 0.9996;
493 const double ta = 0.5 * e2cuadrada *
square(epsilon) *
square(cos(
lat));
494 const double a1 = sin(2 *
lat);
496 const double j2 =
lat + 0.5 *
a1;
497 const double j4 = ((3.0 * j2) +
a2) / 4.0;
498 const double j6 = ((5.0 * j4) + (
a2 *
square(cos(
lat)))) / 3.0;
499 const double alfa = 0.75 * e2cuadrada;
500 const double beta = (5.0 / 3.0) * pow(alfa, 2.0);
501 const double gama = (35.0 / 27.0) * pow(alfa, 3.0);
502 const double Bm = 0.9996 *
c * (
lat - alfa * j2 + beta * j4 - gama * j6);
504 xx = epsilon *
v * (1 + (ta / 3.0)) + 500000;
505 yy = nu *
v * (1 + ta) + Bm;
507 if (yy < 0) yy += 9999999;
510 out_UTM_latitude_band = Letra;
522 const double scale = (1 + d.
dS);
538 const double scale = (1 + d.
dS);
554 const double scale = (1 + d.
dS);
556 const double px =
p.x - d.
Xp;
557 const double py =
p.y - d.
Yp;
558 const double pz =
p.z - d.
Zp;
574 const double scale = (1 + d.
dS);
576 const double px =
p.x - d.
Xp;
577 const double py =
p.y - d.
Yp;
592 o.
x = d.
a *
p.x + d.
b *
p.y + d.
c;
593 o.
y = -d.
b *
p.x + d.
a *
p.y + d.
d;
618 o.
x = d.
a *
p.x + d.
b *
p.y + d.
c;
619 o.
y = d.
d *
p.x + d.
e *
p.y + d.
f;
633 o.
z = (d.
dY *
p.x - d.
dX *
p.y +
p.z) * (1 + d.
dS) + d.
DZ;
660 in_coords_origin, P_geocentric_ref, ellip);
663 P_ref[0] = P_geocentric_ref.
x;
664 P_ref[1] = P_geocentric_ref.
y;
665 P_ref[2] = P_geocentric_ref.
z;
679 AUX_X[0] = -REF_Z[1];
688 REF_X[0] *
p.x + REF_Y[0] *
p.y + REF_Z[0] *
p.z + P_geocentric_ref.
x;
690 REF_X[1] *
p.x + REF_Y[1] *
p.y + REF_Z[1] *
p.z + P_geocentric_ref.
y;
692 REF_X[2] *
p.x + REF_Y[2] *
p.y + REF_Z[2] *
p.z + P_geocentric_ref.
z;
mrpt::math::TPose3D asTPose() const
void transformHelmert2D_TOPCON(const mrpt::math::TPoint2D &p, const TDatumHelmert2D_TOPCON &d, mrpt::math::TPoint2D &o)
Helmert 2D transformation: [ X Y ]_WGS84 = [ dX dY ] + ( 1 + dS ) [ cos(alpha) -sin(alpha); sin(alpha...
double sa
largest semiaxis of the reference ellipsoid (in meters)
A compile-time fixed-size numeric matrix container.
void transformHelmert2D(const mrpt::math::TPoint2D &p, const TDatumHelmert2D &d, mrpt::math::TPoint2D &o)
Helmert 2D transformation: [ X Y ]_WGS84 = [ dX dY ] + ( 1 + dS ) [ cos(alpha) -sin(alpha); sin(alpha...
double x
X,Y,Z coordinates.
double dS
Scale factor (in ppm) (Scale is 1+dS/1e6)
Parameters for a topographic transfomation.
Parameters for a topographic transfomation.
int fix(T x)
Rounds toward zero.
GLenum GLenum GLenum GLenum GLenum scale
double Rx
Rotation components.
void transform7params(const mrpt::math::TPoint3D &in_point, const TDatum7Params &in_datum, mrpt::math::TPoint3D &out_point)
7-parameter Bursa-Wolf transformation: [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY; -RZ 1 ...
void ENU_axes_from_WGS84(double in_longitude_reference_degrees, double in_latitude_reference_degrees, double in_height_reference_meters, mrpt::math::TPose3D &out_ENU, bool only_angles=false)
Returns the East-North-Up (ENU) coordinate system associated to the given point.
A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically...
double dS
Scale factor (in ppm) (Scale is 1+dS/1e6)
bool operator!=(const TCoords &a, const TCoords &o)
bool operator==(const TCoords &a, const TCoords &o)
double dS
Scale factor (Scale is 1+dS)
double Xp
To be substracted to the input point.
void transform1D(const mrpt::math::TPoint3D &p, const TDatum1DTransf &d, mrpt::math::TPoint3D &o)
1D transformation: [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
void geodeticToENU_WGS84(const TGeodeticCoords &in_coords, mrpt::math::TPoint3D &out_ENU_point, const TGeodeticCoords &in_coords_origin)
Coordinates transformation from longitude/latitude/height to ENU (East-North-Up) X/Y/Z coordinates Th...
void geodeticToGeocentric(const TGeodeticCoords &in_coords, TGeocentricCoords &out_point, const TEllipsoid &ellip)
Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with an sp...
double Rx
Rotation components.
A coordinate that is stored as a simple "decimal" angle in degrees, but can be retrieved/set in the f...
void geocentricToENU_WGS84(const mrpt::math::TPoint3D &in_geocentric_point, mrpt::math::TPoint3D &out_ENU_point, const TGeodeticCoords &in_coords_origin)
ENU to EFEC (Geocentric) coordinates.
void transformHelmert3D_TOPCON(const mrpt::math::TPoint3D &p, const TDatumHelmert3D_TOPCON &d, mrpt::math::TPoint3D &o)
Helmert 3D transformation: [ X Y ]_WGS84 = [ dX dY ] + ( 1 + dS ) [ cos(alpha) -sin(alpha); sin(alpha...
void transform10params(const mrpt::math::TPoint3D &in_point, const TDatum10Params &in_datum, mrpt::math::TPoint3D &out_point)
10-parameter Molodensky-Badekas transformation: [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -R...
void crossProduct3D(const T &v0, const U &v1, V &vOut)
Computes the cross product of two 3D vectors, returning a vector normal to both.
double dSx
Scale factor in X and Y.
std::string getAsString() const
Return a std::string in the format "DEGdeg MIN' SEC''".
T square(const T x)
Inline function for the square of a number.
#define ASSERT_(f)
Defines an assertion mechanism.
double Rx
Rotation components (in secs)
Parameters for a topographic transfomation.
void transfInterpolation(const mrpt::math::TPoint3D &p, const TDatumTransfInterpolation &d, mrpt::math::TPoint3D &o)
Interpolation: [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ.
double sb
smallest semiaxis of the reference ellipsoid (in meters)
Parameters for a topographic transfomation.
This base provides a set of functions for maths stuff.
TCoords lon
Longitude (in degrees)
void geodeticToUTM(const TGeodeticCoords &GeodeticCoords, TUTMCoords &UTMCoords, int &UTMZone, char &UTMLatitudeBand, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
void normalize(CONTAINER &c, Scalar valMin, Scalar valMax)
Scales all elements such as the minimum & maximum values are shifted to the given values...
void geocentricToGeodetic(const TGeocentricCoords &in_point, TGeodeticCoords &out_coords, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
Coordinates transformation from geocentric X/Y/Z coordinates to longitude/latitude/height.
double lat
[deg], [deg], hgt over sea level[m]
double dS
Scale factor (Scale is 1+dS)
double dS
Scale factor (Scale is 1+dS)
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void UTMToGeodetic(double X, double Y, int zone, char hem, double &out_lon, double &out_lat, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
Returns the Geodetic coordinates of the UTM input point.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double beta
Distortion angle.
Parameters for a topographic transfomation.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void ENUToGeocentric(const mrpt::math::TPoint3D &in_ENU_point, const TGeodeticCoords &in_coords_origin, TGeocentricCoords &out_coords, const TEllipsoid &ellip)
ENU to geocentric coordinates.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
std::ostream & operator<<(std::ostream &out, const TCoords &o)
double height
Geodetic height (in meters)
void geodeticToGeocentric_WGS84(const TGeodeticCoords &in_coords, mrpt::math::TPoint3D &out_point)
Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with a WGS...
double decimal_value
Also obtained directly through the double(void) operator using a TCoords anywhere were a double is ex...
void GeodeticToUTM(double in_latitude_degrees, double in_longitude_degrees, double &out_UTM_x, double &out_UTM_y, int &out_UTM_zone, char &out_UTM_latitude_band, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
Convert latitude and longitude coordinates into UTM coordinates, computing the corresponding UTM zone...
Parameters for a topographic transfomation.
Parameters for a topographic transfomation.
GLubyte GLubyte GLubyte a
void transformHelmert3D(const mrpt::math::TPoint3D &p, const TDatumHelmert3D &d, mrpt::math::TPoint3D &o)
Helmert3D transformation: [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 -RZ RY; RZ 1 -RX; -RY RX 1 ...
TCoords lat
Latitude (in degrees)
void transform7params_TOPCON(const mrpt::math::TPoint3D &in_point, const TDatum7Params_TOPCON &in_datum, mrpt::math::TPoint3D &out_point)
7-parameter Bursa-Wolf transformation TOPCON: [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY;...