[89] | 1 | // %pacpus:license{
|
---|
| 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %}
|
---|
| 5 | /// @file
|
---|
[162] | 6 | /// @author Jean Laneurit <firstname.surname@utc.fr>
|
---|
| 7 | /// @date April, 2010
|
---|
[89] | 8 | /// @version $Id: geodesie.h 75 2013-01-10 17:04:19Z kurdejma $
|
---|
| 9 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 10 | /// @brief Brief description.
|
---|
| 11 | ///
|
---|
| 12 | /// Detailed description.
|
---|
| 13 |
|
---|
| 14 | #ifndef GEODESIE_H
|
---|
| 15 | #define GEODESIE_H
|
---|
| 16 |
|
---|
| 17 | #include <cmath>
|
---|
| 18 | #include <iostream>
|
---|
| 19 | #include <vector>
|
---|
| 20 |
|
---|
[99] | 21 | #include <QMatrix4x4>
|
---|
| 22 | #include <QVector3D>
|
---|
| 23 |
|
---|
[126] | 24 | #include "PacpusToolsConfig.h"
|
---|
| 25 |
|
---|
[89] | 26 | namespace Geodesie {
|
---|
| 27 |
|
---|
| 28 | #ifndef M_PI
|
---|
| 29 | # define M_PI 3.14159265358979323846
|
---|
| 30 | #endif
|
---|
| 31 | #ifndef M_PI_2
|
---|
| 32 | # define M_PI_2 1.57079632679489661923
|
---|
| 33 | #endif
|
---|
| 34 | #ifndef M_PI_4
|
---|
| 35 | # define M_PI_4 0.78539816339744830962
|
---|
| 36 | #endif
|
---|
| 37 |
|
---|
| 38 | /// 9x9 matrix ???
|
---|
| 39 | ///
|
---|
| 40 | /// @todo Documentation
|
---|
| 41 | /// @todo Rewrite!
|
---|
[162] | 42 | struct PACPUSTOOLS_API Matrice
|
---|
[89] | 43 | {
|
---|
| 44 | /// Copy ctor
|
---|
| 45 | Matrice(const Matrice & A);
|
---|
| 46 | /// Ctor
|
---|
| 47 | Matrice();
|
---|
| 48 | /// @todo Documentation
|
---|
| 49 | void Apply(double v0, double v1, double v2, double & Mv0, double & Mv1, double & Mv2);
|
---|
| 50 |
|
---|
| 51 | /// @todo Documentation
|
---|
| 52 | double c0_l0;
|
---|
| 53 | /// @todo Documentation
|
---|
| 54 | double c1_l0;
|
---|
| 55 | /// @todo Documentation
|
---|
| 56 | double c2_l0;
|
---|
| 57 |
|
---|
| 58 | /// @todo Documentation
|
---|
| 59 | double c0_l1;
|
---|
| 60 | /// @todo Documentation
|
---|
| 61 | double c1_l1;
|
---|
| 62 | /// @todo Documentation
|
---|
| 63 | double c2_l1;
|
---|
| 64 |
|
---|
| 65 | /// @todo Documentation
|
---|
| 66 | double c0_l2;
|
---|
| 67 | /// @todo Documentation
|
---|
| 68 | double c1_l2;
|
---|
| 69 | /// @todo Documentation
|
---|
| 70 | double c2_l2;
|
---|
| 71 | };
|
---|
| 72 |
|
---|
[162] | 73 | PACPUSTOOLS_API Matrice TransMat(const Matrice A);
|
---|
| 74 | PACPUSTOOLS_API Matrice ProdMat(const Matrice A,const Matrice B);
|
---|
| 75 | PACPUSTOOLS_API void Write(const Matrice A,std::ostream& out);
|
---|
[89] | 76 |
|
---|
| 77 | ////////////////////////////////////////////////////////////////////////
|
---|
| 78 | /// @todo Documentation
|
---|
[162] | 79 | class PACPUSTOOLS_API Raf98
|
---|
[89] | 80 | {
|
---|
| 81 | public:
|
---|
| 82 | /// Ctor of Raf98 class.
|
---|
| 83 | Raf98() {}
|
---|
| 84 | /// Dtor of Raf98 class.
|
---|
| 85 | ~Raf98();
|
---|
| 86 |
|
---|
| 87 | /// @todo Documentation
|
---|
| 88 | /// @param s filepath
|
---|
| 89 | bool Load(const std::string & s);
|
---|
| 90 |
|
---|
| 91 | /// @todo Documentation
|
---|
| 92 | /// @param longitude [degrees]
|
---|
| 93 | /// @param latitude [degrees]
|
---|
| 94 | /// @param Hwgs84 Output: interpolated altitude using WGS84 geoid model [meters]
|
---|
| 95 | bool Interpol(double longitude/*deg*/, double latitude/*deg*/, double* Hwgs84) const;
|
---|
| 96 |
|
---|
| 97 | private:
|
---|
| 98 | std::vector<double> m_dvalues;
|
---|
| 99 | double LitGrille(unsigned int c,unsigned int l) const;
|
---|
| 100 | };
|
---|
| 101 |
|
---|
| 102 | ////////////////////////////////////////////////////////////////////////
|
---|
| 103 |
|
---|
| 104 | ////////////////////////////////////////////////////////////////////////
|
---|
[149] | 105 | inline double Deg2Rad(double deg)
|
---|
| 106 | {
|
---|
| 107 | return deg*M_PI/180.0;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | inline double Rad2Deg(double rad)
|
---|
| 111 | {
|
---|
| 112 | return rad*180.0/M_PI;
|
---|
| 113 | }
|
---|
| 114 |
|
---|
[89] | 115 | ////////////////////////////////////////////////////////////////////////
|
---|
| 116 |
|
---|
| 117 | const double a_Lambert93=6378137;
|
---|
| 118 | const double f_Lambert93=1 / 298.257222101;
|
---|
| 119 | const double e_Lambert93=sqrt(f_Lambert93*(2-f_Lambert93));
|
---|
| 120 | const double lambda0_Lambert93=Deg2Rad(3.0);//degres
|
---|
| 121 | const double phi0_Lambert93=Deg2Rad(46.5);
|
---|
| 122 | const double phi1_Lambert93=Deg2Rad(44.0);
|
---|
| 123 | const double phi2_Lambert93=Deg2Rad(49.0);//degres
|
---|
| 124 | const double X0_Lambert93=700000;//
|
---|
| 125 | const double Y0_Lambert93=6600000;//
|
---|
| 126 | const double n_Lambert93 = 0.7256077650;
|
---|
| 127 | const double c_Lambert93 = 11754255.426;
|
---|
| 128 | const double xs_Lambert93 = 700000;
|
---|
| 129 | const double ys_Lambert93 = 12655612.050;
|
---|
| 130 |
|
---|
| 131 | const double GRS_a = 6378137;
|
---|
| 132 | const double GRS_f = 1/298.257222101;
|
---|
| 133 | const double GRS_b = GRS_a*(1-GRS_f);
|
---|
| 134 | const double GRS_e = sqrt((pow(GRS_a,2) - pow(GRS_b,2)) / pow(GRS_a,2));
|
---|
| 135 |
|
---|
| 136 | ////////////////////////////////////////////////////////////////////////
|
---|
[162] | 137 | PACPUSTOOLS_API void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,Matrice in,double& E,double& N,double& h,Matrice& out);
|
---|
| 138 | PACPUSTOOLS_API void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,double& E,double& N,double& h);
|
---|
| 139 | PACPUSTOOLS_API void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,double& lambda,double& phi,double& he);
|
---|
| 140 | PACPUSTOOLS_API void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,Matrice in,double& lambda,double& phi,double& he,Matrice& out);
|
---|
[89] | 141 | /** Convert from geographique to ECEF.
|
---|
| 142 | * @param[in] longitude Longitude in radian.
|
---|
| 143 | * @param[in] latitude Latitude in radian.
|
---|
| 144 | * @param[in] he Height in meter.
|
---|
| 145 | */
|
---|
[162] | 146 | PACPUSTOOLS_API void Geographique_2_ECEF(double longitude, double latitude, double he, double& x, double& y, double& z);
|
---|
[89] | 147 | /** Convert from ECEF two ENU.
|
---|
| 148 | * @param[in] lon0 Longitude of the origin in radian.
|
---|
| 149 | * @param[in] lat0 Latitude of the origin in radian.
|
---|
| 150 | * @param[in] he0 Height of the origin in radian.
|
---|
| 151 | */
|
---|
[162] | 152 | PACPUSTOOLS_API void ECEF_2_ENU(double x,double y,double z,double& e,double& n,double& u,double lon0,double lat0,double he0);
|
---|
[89] | 153 | ////////////////////////////////////////////////////////////////////////
|
---|
| 154 |
|
---|
| 155 | ///ALGO0001
|
---|
| 156 | /// @todo Rename
|
---|
[162] | 157 | PACPUSTOOLS_API double LatitueIsometrique(double latitude,double e);
|
---|
[89] | 158 | ///ALGO0002
|
---|
| 159 | /// @todo Rename
|
---|
[162] | 160 | PACPUSTOOLS_API double LatitueIsometrique2Lat(double latitude_iso,double e,double epsilon);
|
---|
[89] | 161 |
|
---|
| 162 | ///ALGO0003
|
---|
[162] | 163 | PACPUSTOOLS_API void Geo2ProjLambert(
|
---|
[89] | 164 | double lambda,double phi,
|
---|
| 165 | double n, double c,double e,
|
---|
| 166 | double lambdac,double xs,double ys,
|
---|
| 167 | double& X,double& Y);
|
---|
| 168 | ///ALGO0004
|
---|
[162] | 169 | PACPUSTOOLS_API void Proj2GeoLambert(
|
---|
[89] | 170 | double X,double Y,
|
---|
| 171 | double n, double c,double e,
|
---|
| 172 | double lambdac,double xs,double ys,
|
---|
| 173 | double epsilon,
|
---|
| 174 | double& lambda,double& phi);
|
---|
| 175 |
|
---|
[162] | 176 | PACPUSTOOLS_API double ConvMerApp(double longitude);
|
---|
[89] | 177 |
|
---|
| 178 | /**
|
---|
| 179 | Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
|
---|
| 180 | */
|
---|
| 181 | template <typename _T1, typename _T2>
|
---|
| 182 | void cartesianToPolar(const _T1 x, const _T1 y, _T2 & r, _T2 & theta) {
|
---|
| 183 | r = std::sqrt(x*x + y*y);
|
---|
| 184 | theta = std::atan2(x, y);
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | /**
|
---|
| 188 | Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
|
---|
| 189 | */
|
---|
| 190 | template <typename _T1, typename _T2>
|
---|
| 191 | void polarToCartesian(const _T1 r, const _T1 theta, _T2 & x, _T2 & y) {
|
---|
| 192 | x = r * std::cos(theta);
|
---|
| 193 | y = r * std::sin(theta);
|
---|
| 194 | }
|
---|
| 195 |
|
---|
| 196 | /**
|
---|
| 197 | Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi)
|
---|
| 198 | Angles expressed in radians.
|
---|
| 199 | */
|
---|
| 200 | template <typename _T1, typename _T2>
|
---|
| 201 | void cartesianToSpherical(const _T1 x, const _T1 y, const _T1 z, _T2 & r, _T2 & theta, _T2 & phi) {
|
---|
| 202 | r = std::sqrt(x*x + y*y + z*z);
|
---|
| 203 | theta = std::acos(z / r);
|
---|
| 204 | phi = std::atan2(y, x);
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | /**
|
---|
| 208 | Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates.
|
---|
| 209 | Angles expressed in radians.
|
---|
| 210 | */
|
---|
| 211 | template <typename _T1, typename _T2>
|
---|
| 212 | void sphericalToCartesian(const _T1 r, const _T1 theta, const _T1 phi, _T2 & x, _T2 & y, _T2 & z) {
|
---|
| 213 | x = r * std::sin(theta) * std::cos(phi);
|
---|
| 214 | y = r * std::sin(theta) * std::sin(phi);
|
---|
| 215 | z = r * std::cos(theta);
|
---|
| 216 | }
|
---|
| 217 |
|
---|
[162] | 218 | PACPUSTOOLS_API QMatrix4x4 yprenuToMatrix(QVector3D angle, QVector3D position);
|
---|
[99] | 219 |
|
---|
[89] | 220 | } // namespace Geodesie
|
---|
| 221 |
|
---|
| 222 | #endif // GEODESIE_H
|
---|