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;
203 static const precnum_t b = 6356752.3142L;
221 static_cast<double>((N + in_coords.
height) * cos(
lat) * cos(
lon));
223 static_cast<double>((N + in_coords.
height) * cos(
lat) * sin(
lon));
225 static_cast<double>((cos2_ae_earth * N + in_coords.
height) * sin(
lat));
255 static_cast<double>((N + in_coords.
height) * cos(
lat) * cos(
lon));
257 static_cast<double>((N + in_coords.
height) * cos(
lat) * sin(
lon));
259 static_cast<double>((cos2_ae_earth * N + in_coords.
height) * sin(
lat));
269 const double sa2 = ellip.
sa * ellip.
sa;
270 const double sb2 = ellip.
sb * ellip.
sb;
272 const double e2 = (sa2 - sb2) / sa2;
273 const double ep2 = (sa2 - sb2) / sb2;
274 const double p = sqrt(in_point.
x * in_point.
x + in_point.
y * in_point.
y);
275 const double theta = atan2(in_point.
z * ellip.
sa, p * ellip.
sb);
277 out_coords.
lon = atan2(in_point.
y, in_point.
x);
278 out_coords.
lat = atan2(
279 in_point.
z + ep2 * ellip.
sb * sin(theta) * sin(theta) * sin(theta),
280 p - e2 * ellip.
sa * cos(theta) * cos(theta) * cos(theta));
282 const double clat = cos(out_coords.
lat);
283 const double slat = sin(out_coords.
lat);
284 const double N = sa2 / sqrt(sa2 * clat * clat + sb2 * slat * slat);
286 out_coords.
height = p / clat - N;
296 double X,
double Y,
int huso,
char hem,
double& out_lon ,
299 ASSERT_(hem ==
's' || hem ==
'S' || hem ==
'n' || hem ==
'N');
302 if (hem ==
's' || hem ==
'S') Y = Y - 1e7;
309 const precnum_t latp = Y / (6366197.724 * 0.9996);
312 const precnum_t v = c * 0.9996 / sqrt(1 + ep2 * clp2);
317 const precnum_t J4 = 0.75 * J2 + 0.25 * A2;
318 const precnum_t J6 = (5 * J4 + A2 * clp2) / 3;
321 const precnum_t beta = (5.0 / 3.0) * alp * alp;
322 const precnum_t gam = (35.0 / 27.0) * alp * alp * alp;
323 const precnum_t B = 0.9996 * c * (latp - alp * J2 + beta * J4 - gam * J6);
327 const precnum_t nu = nb * (1 - psi) + latp;
329 const precnum_t dlon = atan2(she, cos(nu));
330 const precnum_t tau = atan2(cos(dlon) * tan(nu), 1);
332 out_lon =
static_cast<double>(
RAD2DEG(dlon) + lon0);
333 out_lat =
static_cast<double>(
RAD2DEG(
335 (1 + ep2 * clp2 - 1.5 * ep2 * sin(latp) * cos(latp) * (tau - latp)) *
341 char& UTMLatitudeBand,
const TEllipsoid& ellip)
343 const double la = GeodeticCoords.
lat;
388 const int Huso =
mrpt::fix((GeodeticCoords.
lon / 6) + 31);
394 const precnum_t ep2 = (sa * sa - sb * sb) / (sb * sb);
406 const precnum_t v = 0.9996 * c / sqrt(1 + ep2 * clat * clat);
411 const precnum_t J4 = 0.75 * J2 + 0.25 * A2;
412 const precnum_t J6 = (5.0 * J4 + A2 * clat * clat) / 3;
414 const precnum_t nbet = (5.0 / 3.0) * nalp * nalp;
415 const precnum_t ngam = (35.0 / 27.0) * nalp * nalp * nalp;
416 const precnum_t B = 0.9996 * c * (
lat - nalp * J2 + nbet * J4 - ngam * J6);
418 UTMCoords.
x =
static_cast<double>(
eps * v * (1 + psi / 3.0) + 500000);
419 UTMCoords.
y =
static_cast<double>(nu * v * (1 + psi) + B);
420 UTMCoords.
z =
static_cast<double>(GeodeticCoords.
height);
423 UTMLatitudeBand = Letra;
430 double la,
double lo,
double& xx,
double& yy,
int& out_UTM_zone,
431 char& out_UTM_latitude_band,
const TEllipsoid& ellip)
437 const double sa = ellip.
sa;
438 const double sb = ellip.
sb;
439 const double e2 = (sqrt((sa * sa) - (sb * sb))) / sb;
441 const double e2cuadrada = e2 * e2;
443 const double c = (sa * sa) / sb;
448 const int Huso =
mrpt::fix((lo / 6) + 31);
449 double S = ((Huso * 6) - 183);
495 const double a = cos(
lat) * sin(deltaS);
496 const double epsilon = 0.5 * log((1 + a) / (1 - a));
497 const double nu = atan(tan(
lat) / cos(deltaS)) -
lat;
498 const double v = (c / sqrt((1 + (e2cuadrada *
square(cos(
lat)))))) * 0.9996;
499 const double ta = 0.5 * e2cuadrada *
square(epsilon) *
square(cos(
lat));
500 const double a1 = sin(2 *
lat);
502 const double j2 =
lat + 0.5 *
a1;
503 const double j4 = ((3.0 * j2) +
a2) / 4.0;
504 const double j6 = ((5.0 * j4) + (
a2 *
square(cos(
lat)))) / 3.0;
505 const double alfa = 0.75 * e2cuadrada;
506 const double beta = (5.0 / 3.0) * pow(alfa, 2.0);
507 const double gama = (35.0 / 27.0) * pow(alfa, 3.0);
508 const double Bm = 0.9996 * c * (
lat - alfa * j2 + beta * j4 - gama * j6);
510 xx = epsilon * v * (1 + (ta / 3.0)) + 500000;
511 yy = nu * v * (1 + ta) + Bm;
513 if (yy < 0) yy += 9999999;
516 out_UTM_latitude_band = Letra;
528 const double scale = (1 + d.
dS);
530 o.
x = d.
dX + scale * (p.
x + p.
y * d.
Rz - p.
z * d.
Ry);
531 o.
y = d.
dY + scale * (-p.
x * d.
Rz + p.
y + p.
z * d.
Rx);
532 o.
z = d.
dZ + scale * (p.
x * d.
Ry - p.
y * d.
Rx + p.
z);
544 const double scale = (1 + d.
dS);
560 const double scale = (1 + d.
dS);
562 const double px = p.
x - d.
Xp;
563 const double py = p.
y - d.
Yp;
564 const double pz = p.
z - d.
Zp;
566 o.
x = d.
dX + scale * (px + py * d.
Rz - pz * d.
Ry) + d.
Xp;
567 o.
y = d.
dY + scale * (-px * d.
Rz + py + pz * d.
Rx) + d.
Yp;
568 o.
z = d.
dZ + scale * (px * d.
Ry - py * d.
Rx + pz) + d.
Zp;
580 const double scale = (1 + d.
dS);
582 const double px = p.
x - d.
Xp;
583 const double py = p.
y - d.
Yp;
598 o.
x = d.
a * p.
x + d.
b * p.
y + d.
c;
599 o.
y = -d.
b * p.
x + d.
a * p.
y + d.
d;
624 o.
x = d.
a * p.
x + d.
b * p.
y + d.
c;
625 o.
y = d.
d * p.
x + d.
e * p.
y + d.
f;
639 o.
z = (d.
dY * p.
x - d.
dX * p.
y + p.
z) * (1 + d.
dS) + d.
DZ;
666 in_coords_origin, P_geocentric_ref, ellip);
669 P_ref[0] = P_geocentric_ref.
x;
670 P_ref[1] = P_geocentric_ref.
y;
671 P_ref[2] = P_geocentric_ref.
z;
685 AUX_X[0] = -REF_Z[1];
694 REF_X[0] * p.
x + REF_Y[0] * p.
y + REF_Z[0] * p.
z + P_geocentric_ref.
x;
696 REF_X[1] * p.
x + REF_Y[1] * p.
y + REF_Z[1] * p.
z + P_geocentric_ref.
y;
698 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.
int fix(T x)
Rounds toward zero.
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 dS
Scale factor (in ppm) (Scale is 1+dS/1e6)
Parameters for a topographic transfomation.
Parameters for a topographic transfomation.
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''".
#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.
return_t square(const num_t x)
Inline function for the square of a number.
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).
mrpt::vision::TStereoCalibResults out
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.
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;...