[62] | 1 | // This file is part of the PACPUS framework distributed under the
|
---|
| 2 | // CECILL-C License, Version 1.0.
|
---|
| 3 | //
|
---|
| 4 | /// @author Firstname Surname <firstname.surname@utc.fr>
|
---|
| 5 | /// @date Month, Year
|
---|
| 6 | /// @version $Id$
|
---|
| 7 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 8 | /// @brief Brief description.
|
---|
| 9 | ///
|
---|
| 10 | /// Detailed description.
|
---|
[31] | 11 |
|
---|
[3] | 12 | #ifndef GEODESIE_H
|
---|
| 13 | #define GEODESIE_H
|
---|
| 14 |
|
---|
| 15 | #include <cmath>
|
---|
| 16 | #include <iostream>
|
---|
| 17 | #include <vector>
|
---|
| 18 |
|
---|
| 19 | namespace Geodesie {
|
---|
| 20 |
|
---|
| 21 | #ifndef M_PI
|
---|
| 22 | # define M_PI 3.14159265358979323846
|
---|
| 23 | #endif
|
---|
| 24 | #ifndef M_PI_2
|
---|
| 25 | # define M_PI_2 1.57079632679489661923
|
---|
| 26 | #endif
|
---|
| 27 | #ifndef M_PI_4
|
---|
| 28 | # define M_PI_4 0.78539816339744830962
|
---|
| 29 | #endif
|
---|
| 30 |
|
---|
| 31 | ////////////////////////////////////////////////////////////////////////
|
---|
| 32 | struct Matrice {
|
---|
| 33 | Matrice(const Matrice & A);
|
---|
| 34 | Matrice();
|
---|
| 35 | void Apply(double v0, double v1, double v2, double & Mv0, double & Mv1, double & Mv2);
|
---|
| 36 | double c0_l0;double c1_l0;double c2_l0;
|
---|
| 37 | double c0_l1;double c1_l1;double c2_l1;
|
---|
| 38 | double c0_l2;double c1_l2;double c2_l2;
|
---|
| 39 | }; // class
|
---|
| 40 |
|
---|
| 41 | Matrice TransMat(const Matrice A);
|
---|
| 42 |
|
---|
| 43 | Matrice ProdMat(const Matrice A,const Matrice B);
|
---|
| 44 | void Write(const Matrice A,std::ostream& out);
|
---|
| 45 |
|
---|
| 46 | ////////////////////////////////////////////////////////////////////////
|
---|
| 47 | class Raf98 {
|
---|
| 48 | private :
|
---|
| 49 | std::vector<double> m_dvalues;
|
---|
| 50 | double LitGrille(unsigned int c,unsigned int l) const;
|
---|
| 51 | public :
|
---|
| 52 | ~Raf98();
|
---|
| 53 | Raf98() {}
|
---|
| 54 | bool Load(const std::string & s);
|
---|
| 55 | bool Interpol(double longitude/*deg*/, double latitude/*deg*/, double* Hwgs84) const;
|
---|
| 56 | }; // class
|
---|
| 57 | ////////////////////////////////////////////////////////////////////////
|
---|
| 58 |
|
---|
| 59 | ////////////////////////////////////////////////////////////////////////
|
---|
| 60 | inline double Deg2Rad(double deg) {return deg*M_PI/180.0;}
|
---|
| 61 | inline double Rad2Deg(double rad) {return rad*180.0/M_PI;}
|
---|
| 62 | ////////////////////////////////////////////////////////////////////////
|
---|
| 63 |
|
---|
| 64 | const double a_Lambert93=6378137;
|
---|
| 65 | const double f_Lambert93=1 / 298.257222101;
|
---|
| 66 | const double e_Lambert93=sqrt(f_Lambert93*(2-f_Lambert93));
|
---|
| 67 | const double lambda0_Lambert93=Deg2Rad(3.0);//degres
|
---|
| 68 | const double phi0_Lambert93=Deg2Rad(46.5);
|
---|
| 69 | const double phi1_Lambert93=Deg2Rad(44.0);
|
---|
| 70 | const double phi2_Lambert93=Deg2Rad(49.0);//degres
|
---|
| 71 | const double X0_Lambert93=700000;//
|
---|
| 72 | const double Y0_Lambert93=6600000;//
|
---|
| 73 | const double n_Lambert93 = 0.7256077650;
|
---|
| 74 | const double c_Lambert93 = 11754255.426;
|
---|
| 75 | const double xs_Lambert93 = 700000;
|
---|
| 76 | const double ys_Lambert93 = 12655612.050;
|
---|
| 77 |
|
---|
| 78 | const double GRS_a = 6378137;
|
---|
| 79 | const double GRS_f = 1/298.257222101;
|
---|
| 80 | const double GRS_b = GRS_a*(1-GRS_f);
|
---|
| 81 | const double GRS_e = sqrt((pow(GRS_a,2) - pow(GRS_b,2)) / pow(GRS_a,2));
|
---|
| 82 |
|
---|
| 83 | ////////////////////////////////////////////////////////////////////////
|
---|
| 84 | void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,Matrice in,double& E,double& N,double& h,Matrice& out);
|
---|
| 85 | void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,double& E,double& N,double& h);
|
---|
| 86 | void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,double& lambda,double& phi,double& he);
|
---|
| 87 | void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,Matrice in,double& lambda,double& phi,double& he,Matrice& out);
|
---|
| 88 | /** Convert from geographique to ECEF.
|
---|
| 89 | * @param[in] longitude Longitude in radian.
|
---|
| 90 | * @param[in] latitude Latitude in radian.
|
---|
| 91 | * @param[in] he Height in meter.
|
---|
| 92 | */
|
---|
| 93 | void Geographique_2_ECEF(double longitude, double latitude, double he, double& x, double& y, double& z);
|
---|
| 94 | /** Convert from ECEF two ENU.
|
---|
| 95 | * @param[in] lon0 Longitude of the origin in radian.
|
---|
| 96 | * @param[in] lat0 Latitude of the origin in radian.
|
---|
| 97 | * @param[in] he0 Height of the origin in radian.
|
---|
| 98 | */
|
---|
| 99 | void ECEF_2_ENU(double x,double y,double z,double& e,double& n,double& u,double lon0,double lat0,double he0);
|
---|
| 100 | ////////////////////////////////////////////////////////////////////////
|
---|
| 101 |
|
---|
| 102 | //ALGO0001
|
---|
| 103 | double LatitueIsometrique(double latitude,double e);
|
---|
| 104 | //ALGO0002
|
---|
| 105 | double LatitueIsometrique2Lat(double latitude_iso,double e,double epsilon);
|
---|
| 106 |
|
---|
| 107 | //ALGO0003
|
---|
| 108 | void Geo2ProjLambert(
|
---|
| 109 | double lambda,double phi,
|
---|
| 110 | double n, double c,double e,
|
---|
| 111 | double lambdac,double xs,double ys,
|
---|
| 112 | double& X,double& Y);
|
---|
| 113 | //ALGO0004
|
---|
| 114 | void Proj2GeoLambert(
|
---|
| 115 | double X,double Y,
|
---|
| 116 | double n, double c,double e,
|
---|
| 117 | double lambdac,double xs,double ys,
|
---|
| 118 | double epsilon,
|
---|
| 119 | double& lambda,double& phi);
|
---|
| 120 |
|
---|
| 121 | double ConvMerApp(double longitude);
|
---|
| 122 |
|
---|
| 123 | /**
|
---|
| 124 | Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
|
---|
| 125 | */
|
---|
| 126 | template <typename _T1, typename _T2>
|
---|
| 127 | void cartesianToPolar(const _T1 x, const _T1 y, _T2 & r, _T2 & theta) {
|
---|
| 128 | r = std::sqrt(x*x + y*y);
|
---|
| 129 | theta = std::atan2(x, y);
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | /**
|
---|
| 133 | Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
|
---|
| 134 | */
|
---|
| 135 | template <typename _T1, typename _T2>
|
---|
| 136 | void polarToCartesian(const _T1 r, const _T1 theta, _T2 & x, _T2 & y) {
|
---|
| 137 | x = r * std::cos(theta);
|
---|
| 138 | y = r * std::sin(theta);
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | /**
|
---|
| 142 | Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi)
|
---|
| 143 | Angles expressed in radians.
|
---|
| 144 | */
|
---|
| 145 | template <typename _T1, typename _T2>
|
---|
| 146 | void cartesianToSpherical(const _T1 x, const _T1 y, const _T1 z, _T2 & r, _T2 & theta, _T2 & phi) {
|
---|
| 147 | r = std::sqrt(x*x + y*y + z*z);
|
---|
| 148 | theta = std::acos(z / r);
|
---|
| 149 | phi = std::atan2(y, x);
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | /**
|
---|
| 153 | Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates.
|
---|
| 154 | Angles expressed in radians.
|
---|
| 155 | */
|
---|
| 156 | template <typename _T1, typename _T2>
|
---|
| 157 | void sphericalToCartesian(const _T1 r, const _T1 theta, const _T1 phi, _T2 & x, _T2 & y, _T2 & z) {
|
---|
| 158 | x = r * std::sin(theta) * std::cos(phi);
|
---|
| 159 | y = r * std::sin(theta) * std::sin(phi);
|
---|
| 160 | z = r * std::cos(theta);
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | } // namespace Geodesie
|
---|
| 164 |
|
---|
| 165 | #endif // GEODESIE_H
|
---|