35 #ifdef HAVE_LONG_DOUBLE 60 const double clat = cos(
DEG2RAD(in_coords_origin.
lat)), slat = sin(
DEG2RAD(in_coords_origin.
lat));
61 const double clon = cos(
DEG2RAD(in_coords_origin.
lon)), slon = sin(
DEG2RAD(in_coords_origin.
lon));
69 out_ENU_point.
x = -slon*P_geocentric.
x + clon*P_geocentric.
y;
70 out_ENU_point.
y = -clon*slat*P_geocentric.
x -slon*slat*P_geocentric.
y + clat*P_geocentric.
z;
71 out_ENU_point.
z = clon*clat*P_geocentric.
x + slon*clat*P_geocentric.
y +slat*P_geocentric.
z;
75 const std::vector<mrpt::math::TPoint3D> &in_geocentric_points,
76 std::vector<mrpt::math::TPoint3D> &out_ENU_points,
83 const double clat = cos(
DEG2RAD(in_coords_origin.
lat)), slat = sin(
DEG2RAD(in_coords_origin.
lat));
84 const double clon = cos(
DEG2RAD(in_coords_origin.
lon)), slon = sin(
DEG2RAD(in_coords_origin.
lon));
86 const size_t N= in_geocentric_points.size();
87 out_ENU_points.resize(N);
88 for (
size_t i=0;i<N;i++)
95 out_ENU_points[i].x = -slon*P_geocentric.
x + clon*P_geocentric.
y;
96 out_ENU_points[i].y = -clon*slat*P_geocentric.
x -slon*slat*P_geocentric.
y + clat*P_geocentric.
z;
97 out_ENU_points[i].z = clon*clat*P_geocentric.
x + slon*clat*P_geocentric.
y +slat*P_geocentric.
z;
129 double in_longitude_reference_degrees,
130 double in_latitude_reference_degrees,
131 double in_height_reference_meters,
139 TGeodeticCoords(in_latitude_reference_degrees, in_longitude_reference_degrees, in_height_reference_meters),
142 const double clat = cos(
DEG2RAD(in_latitude_reference_degrees)), slat = sin(
DEG2RAD(in_latitude_reference_degrees));
143 const double clon = cos(
DEG2RAD(in_longitude_reference_degrees)), slon = sin(
DEG2RAD(in_longitude_reference_degrees));
146 HM(0,0) = -slon; HM(0,1) = -clon*slat; HM(0,2) = clon*clat;
147 HM(1,0) = clon; HM(1,1) = -slon*slat; HM(1,2) = slon*clat;
148 HM(2,0) = 0; HM(2,1) = clat; HM(2,2) = slat;
189 out_point.
z = (cos2_ae_earth*N+in_coords.
height)*sin(
lat);
216 out_point.
z = (cos2_ae_earth*N+in_coords.
height)*sin(
lat);
227 const double sa2 = ellip.
sa*ellip.
sa;
228 const double sb2 = ellip.
sb*ellip.
sb;
230 const double e2 = (sa2-sb2)/sa2;
231 const double ep2 = (sa2-sb2)/sb2;
232 const double p = sqrt( in_point.
x*in_point.
x + in_point.
y*in_point.
y );
233 const double theta = atan2(in_point.
z*ellip.
sa,
p*ellip.
sb);
235 out_coords.
lon = atan2( in_point.
y, in_point.
x );
236 out_coords.
lat = atan2( in_point.
z + ep2*ellip.
sb*sin(theta)*sin(theta)*sin(theta),
p-e2*ellip.
sa*cos(theta)*cos(theta)*cos(theta) );
238 const double clat = cos( out_coords.
lat );
239 const double slat = sin( out_coords.
lat );
240 const double N = sa2/sqrt( sa2*clat*clat+sb2*slat*slat );
242 out_coords.
height =
p/clat - N;
260 ASSERT_(hem==
's' || hem==
'S' || hem==
'n' || hem==
'N');
263 if( hem ==
's' || hem ==
'S' )
271 const precnum_t latp = Y/( 6366197.724*0.9996 );
283 const precnum_t beta = (5.0/3.0)*alp*alp;
284 const precnum_t gam = (35.0/27.0)*alp*alp*alp;
285 const precnum_t B = 0.9996*
c*( latp-alp*J2+beta*J4-gam*J6 );
291 const precnum_t dlon = atan2(she,cos(nu));
292 const precnum_t tau = atan2(cos(dlon)*tan(nu),1);
294 out_lon =
RAD2DEG( dlon )+lon0;
295 out_lat =
RAD2DEG( latp + (1+ep2*clp2-1.5*ep2*sin(latp)*cos(latp)*(tau-latp))*(tau-latp) );
303 char &UTMLatitudeBand,
306 const double la = GeodeticCoords.
lat;
308 if (la<-72) Letra=
'C';
309 else if (la<-64) Letra=
'D';
310 else if (la<-56) Letra=
'E';
311 else if (la<-48) Letra=
'F';
312 else if (la<-40) Letra=
'G';
313 else if (la<-32) Letra=
'H';
314 else if (la<-24) Letra=
'J';
315 else if (la<-16) Letra=
'K';
316 else if (la<-8) Letra=
'L';
317 else if (la<0) Letra=
'M';
318 else if (la<8) Letra=
'N';
319 else if (la<16) Letra=
'P';
320 else if (la<24) Letra=
'Q';
321 else if (la<32) Letra=
'R';
322 else if (la<40) Letra=
'S';
323 else if (la<48) Letra=
'T';
324 else if (la<56) Letra=
'U';
325 else if (la<64) Letra=
'V';
326 else if (la<72) Letra=
'W';
337 const precnum_t ep2 = (sa*sa-sb*sb)/(sb*sb);
349 const precnum_t v = 0.9996*
c/sqrt( 1+ep2*clat*clat );
355 const precnum_t J6 = (5.0*J4+A2*clat*clat)/3;
357 const precnum_t nbet = (5.0/3.0)*nalp*nalp;
358 const precnum_t ngam = (35.0/27.0)*nalp*nalp*nalp;
361 UTMCoords.
x =
eps*
v*(1+psi/3.0)+500000;
362 UTMCoords.
y = nu*
v*(1+psi)+B;
363 UTMCoords.
z = GeodeticCoords.
height;
366 UTMLatitudeBand = Letra;
379 char &out_UTM_latitude_band,
385 const double sa = ellip.
sa;
386 const double sb = ellip.
sb;
387 const double e2 = (sqrt((sa*sa) - (sb*sb)))/sb;
389 const double e2cuadrada = e2*e2;
391 const double c = ( sa*sa )/sb;
397 double S = ( ( Huso * 6 ) - 183 );
402 if (la<-72) Letra=
'C';
403 else if (la<-64) Letra=
'D';
404 else if (la<-56) Letra=
'E';
405 else if (la<-48) Letra=
'F';
406 else if (la<-40) Letra=
'G';
407 else if (la<-32) Letra=
'H';
408 else if (la<-24) Letra=
'J';
409 else if (la<-16) Letra=
'K';
410 else if (la<-8) Letra=
'L';
411 else if (la<0) Letra=
'M';
412 else if (la<8) Letra=
'N';
413 else if (la<16) Letra=
'P';
414 else if (la<24) Letra=
'Q';
415 else if (la<32) Letra=
'R';
416 else if (la<40) Letra=
'S';
417 else if (la<48) Letra=
'T';
418 else if (la<56) Letra=
'U';
419 else if (la<64) Letra=
'V';
420 else if (la<72) Letra=
'W';
423 const double a = cos(
lat) * sin(deltaS);
424 const double epsilon = 0.5 * log( ( 1 +
a) / ( 1 -
a ) );
425 const double nu = atan( tan(
lat) / cos(deltaS) ) -
lat;
426 const double v = (
c / sqrt( ( 1 + ( e2cuadrada *
square(cos(
lat)) ) ) ) ) * 0.9996;
427 const double ta = 0.5 * e2cuadrada *
square(epsilon) *
square( cos(
lat) );
428 const double a1 = sin( 2 *
lat );
430 const double j2 =
lat + 0.5*
a1;
431 const double j4 = ( ( 3.0 * j2 ) +
a2 ) / 4.0;
432 const double j6 = ( ( 5.0 * j4 ) + (
a2 *
square( cos(
lat) ) ) ) / 3.0;
433 const double alfa = 0.75 * e2cuadrada;
434 const double beta = (5.0/3.0) * pow(alfa, 2.0);
435 const double gama = (35.0/27.0) * pow(alfa,3.0);
436 const double Bm = 0.9996 *
c * (
lat - alfa * j2 + beta * j4 - gama * j6 );
438 xx = epsilon *
v * ( 1 + ( ta / 3.0 ) ) + 500000;
439 yy = nu *
v * ( 1 + ta ) + Bm;
445 out_UTM_latitude_band = Letra;
492 const double px =
p.x - d.
Xp;
493 const double py =
p.y - d.
Yp;
494 const double pz =
p.z - d.
Zp;
512 const double px =
p.x - d.
Xp;
513 const double py =
p.y - d.
Yp;
528 o.
x = d.
a*
p.x + d.
b*
p.y+d.
c;
529 o.
y = -d.
b*
p.x+d.
a*
p.y+d.
d;
554 o.
x = d.
a*
p.x + d.
b*
p.y + d.
c;
555 o.
y = d.
d*
p.x + d.
e*
p.y + d.
f;
570 o.
z = (d.
dY *
p.x - d.
dX *
p.y +
p.z)*(1 + d.
dS) + d.
DZ;
603 P_ref[0] = P_geocentric_ref.
x;
604 P_ref[1] = P_geocentric_ref.
y;
605 P_ref[2] = P_geocentric_ref.
z;
626 out_coords.
x = REF_X[0]*
p.x + REF_Y[0]*
p.y + REF_Z[0]*
p.z + P_geocentric_ref.
x;
627 out_coords.
y = REF_X[1]*
p.x + REF_Y[1]*
p.y + REF_Z[1]*
p.z + P_geocentric_ref.
y;
628 out_coords.
z = REF_X[2]*
p.x + REF_Y[2]*
p.y + REF_Z[2]*
p.z + P_geocentric_ref.
z;
void TOPO_IMPEXP 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)
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void TOPO_IMPEXP 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.
GLenum GLenum GLenum GLenum GLenum scale
void TOPO_IMPEXP 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 ...
double Rz
Rotation components.
void TOPO_IMPEXP 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 Rz
Rotation components (in secs)
double dS
Scale factor (in ppm) (Scale is 1+dS/1e6)
bool TOPO_IMPEXP operator!=(const TCoords &a, const TCoords &o)
double dSy
Scale factor in X and Y.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
bool TOPO_IMPEXP operator==(const TCoords &a, const TCoords &o)
double dS
Scale factor (Scale is 1+dS)
double z
X,Y,Z coordinates.
void TOPO_IMPEXP 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 TOPO_IMPEXP 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 TOPO_IMPEXP 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...
A coordinate that is stored as a simple "decimal" angle in degrees, but can be retrieved/set in the f...
void TOPO_IMPEXP 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 TOPO_IMPEXP 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 TOPO_IMPEXP 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.
T square(const T x)
Inline function for the square of a number.
std::string getAsString() const
Return a std::string in the format "DEGdeg MIN' SEC''".
Parameters for a topographic transfomation.
void TOPO_IMPEXP 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.
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
double Rz
Rotation components.
TCoords lon
Longitude (in degrees)
void TOPO_IMPEXP geodeticToUTM(const TGeodeticCoords &GeodeticCoords, TUTMCoords &UTMCoords, int &UTMZone, char &UTMLatitudeBand, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
void TOPO_IMPEXP 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 Zp
To be substracted to the input point.
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 TOPO_IMPEXP 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.
double A1
UTC constant and 1st order terms.
void normalize(Scalar valMin, Scalar valMax)
Scales all elements such as the minimum & maximum values are shifted to the given values...
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 TOPO_IMPEXP 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 TOPO_IMPEXP & operator<<(std::ostream &out, const TCoords &o)
double height
Geodetic height (in meters)
void TOPO_IMPEXP 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 TOPO_IMPEXP 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 TOPO_IMPEXP 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)
int fix(T x)
Rounds toward zero.
void TOPO_IMPEXP 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;...