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