source: pacpusframework/trunk/include/Pacpus/PacpusTools/geodesie.h@ 283

Last change on this file since 283 was 224, checked in by Marek Kurdej, 11 years ago

Silenced MSVC warnings.

  • Property svn:executable set to *
File size: 7.9 KB
Line 
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
6/// @author Marek Kurdej <firstname.surname@utc.fr>
7/// @author Jean Laneurit <firstname.surname@utc.fr>
8/// @date April, 2010
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
18#ifdef _MSC_VER
19# pragma warning(push)
20# pragma warning(disable: 4251 4275)
21#endif // _MSC_VER
22
23#include "PacpusToolsConfig.h"
24
25#include <Pacpus/kernel/pacpus.h>
26
27#include <boost/math/constants/constants.hpp>
28#include <boost/operators.hpp>
29#include <cmath>
30#include <iostream>
31#include <vector>
32
33class QMatrix4x4;
34class QVector3D;
35
36namespace Geodesy
37{
38
39/// 3x3 matrix ???
40///
41/// @todo Documentation
42/// @todo Rewrite!
43struct PACPUSTOOLS_API Matrice
44 : boost::multipliable<Matrice>
45{
46 /// Copy ctor
47 Matrice(Matrice const& A);
48 /// Ctor
49 Matrice();
50 /// Ctor
51 Matrice(
52 double l0c0, double l0c1, double l0c2,
53 double l1c0, double l1c1, double l1c2,
54 double l2c0, double l2c1, double l2c2
55 );
56
57 /// @todo Documentation
58 void Apply(double v0, double v1, double v2, double& Mv0, double& Mv1, double& Mv2);
59
60 Matrice& operator*=(Matrice const& other);
61
62 /// @todo Documentation
63 double c0_l0;
64 /// @todo Documentation
65 double c1_l0;
66 /// @todo Documentation
67 double c2_l0;
68
69 /// @todo Documentation
70 double c0_l1;
71 /// @todo Documentation
72 double c1_l1;
73 /// @todo Documentation
74 double c2_l1;
75
76 /// @todo Documentation
77 double c0_l2;
78 /// @todo Documentation
79 double c1_l2;
80 /// @todo Documentation
81 double c2_l2;
82};
83
84PACPUSTOOLS_API Matrice TransMat(Matrice const& A);
85PACPUSTOOLS_API PACPUS_DEPRECATED_MSG(Matrice ProdMat(Matrice const& A, Matrice const& B), "use Matrice::operator *");
86PACPUSTOOLS_API PACPUS_DEPRECATED_MSG(void Write(Matrice const& A, std::ostream& out), "use operator<<");
87PACPUSTOOLS_API std::ostream& operator<<(std::ostream& os, Matrice const& A);
88
89////////////////////////////////////////////////////////////////////////
90/// @todo Documentation
91class PACPUSTOOLS_API Raf98
92{
93public:
94 /// Ctor of Raf98 class.
95 Raf98();
96
97 /// Dtor of Raf98 class.
98 ~Raf98();
99
100 /// @todo Documentation
101 /// @param filepath Path to the input file with RAF98 data.
102 bool Load(const std::string& filepath);
103
104 /// @todo Documentation
105 /// @param longitude [degrees]
106 /// @param latitude [degrees]
107 /// @param Hwgs84 Output: interpolated altitude using WGS84 geoid model [meters]
108 bool Interpol(double longitude /*deg*/, double latitude /*deg*/, double* Hwgs84) const;
109
110private:
111 std::vector<double> m_dvalues;
112 double LitGrille(unsigned int c, unsigned int l) const;
113};
114
115////////////////////////////////////////////////////////////////////////
116
117////////////////////////////////////////////////////////////////////////
118inline double Deg2Rad(double deg)
119{
120 using ::boost::math::constants::pi;
121 return deg * pi<double>() / 180.0;
122}
123
124inline double Rad2Deg(double rad)
125{
126 using ::boost::math::constants::pi;
127 return rad * 180.0 / pi<double>();
128}
129
130////////////////////////////////////////////////////////////////////////
131
132const double a_Lambert93 = 6378137;
133const double f_Lambert93 = 1 / 298.257222101;
134const double e_Lambert93 = sqrt(f_Lambert93 * (2 - f_Lambert93));
135const double lambda0_Lambert93 = Deg2Rad(3.0); //degres
136const double phi0_Lambert93 = Deg2Rad(46.5);
137const double phi1_Lambert93 = Deg2Rad(44.0);
138const double phi2_Lambert93 = Deg2Rad(49.0); //degres
139const double X0_Lambert93 = 700000; //
140const double Y0_Lambert93 = 6600000; //
141const double n_Lambert93 = 0.7256077650;
142const double c_Lambert93 = 11754255.426;
143const double xs_Lambert93 = 700000;
144const double ys_Lambert93 = 12655612.050;
145
146const double GRS_a = 6378137;
147const double GRS_f = 1 / 298.257222101;
148const double GRS_b = GRS_a * (1 - GRS_f);
149const double GRS_e = sqrt((pow(GRS_a, 2) - pow(GRS_b, 2)) / pow(GRS_a, 2));
150
151////////////////////////////////////////////////////////////////////////
152PACPUSTOOLS_API void Geographique_2_Lambert93(const Raf98& raf98, double lambda, double phi, double he, Matrice in, double& E, double& N, double& h, Matrice& out);
153PACPUSTOOLS_API void Geographique_2_Lambert93(const Raf98& raf98, double lambda, double phi, double he, double& E, double& N, double& h);
154PACPUSTOOLS_API void Lambert93_2_Geographique(const Raf98& raf98, double E, double N, double h, double& lambda, double& phi, double& he);
155PACPUSTOOLS_API void Lambert93_2_Geographique(const Raf98& raf98, double E, double N, double h, Matrice in, double& lambda, double& phi, double& he, Matrice& out);
156/** Convert from geographique to ECEF.
157 * @param[in] longitude Longitude in radian.
158 * @param[in] latitude Latitude in radian.
159 * @param[in] he Height in meter.
160 */
161PACPUSTOOLS_API void Geographique_2_ECEF(double longitude, double latitude, double he, double& x, double& y, double& z);
162/** Convert from ECEF two ENU.
163 * @param[in] lon0 Longitude of the origin in radian.
164 * @param[in] lat0 Latitude of the origin in radian.
165 * @param[in] he0 Height of the origin in radian.
166 */
167PACPUSTOOLS_API void ECEF_2_ENU(double x, double y, double z, double& e, double& n, double& u, double lon0, double lat0, double he0);
168////////////////////////////////////////////////////////////////////////
169
170///ALGO0001
171/// @todo Rename
172PACPUSTOOLS_API double LatitueIsometrique(double latitude, double e);
173///ALGO0002
174/// @todo Rename
175PACPUSTOOLS_API double LatitueIsometrique2Lat(double latitude_iso, double e, double epsilon);
176
177///ALGO0003
178PACPUSTOOLS_API void Geo2ProjLambert(
179 double lambda, double phi,
180 double n, double c, double e,
181 double lambdac, double xs, double ys,
182 double& X, double& Y);
183///ALGO0004
184PACPUSTOOLS_API void Proj2GeoLambert(
185 double X, double Y,
186 double n, double c, double e,
187 double lambdac, double xs, double ys,
188 double epsilon,
189 double& lambda, double& phi);
190
191PACPUSTOOLS_API double ConvMerApp(double longitude);
192
193/// Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
194template <typename _T1, typename _T2>
195void cartesianToPolar(const _T1 x, const _T1 y, _T2& r, _T2& theta)
196{
197 using ::std::atan2;
198 using ::std::sqrt;
199
200 r = sqrt(x * x + y * y);
201 theta = atan2(x, y);
202}
203
204/// Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
205template <typename _T1, typename _T2>
206void polarToCartesian(const _T1 r, const _T1 theta, _T2& x, _T2& y)
207{
208 using ::std::cos;
209 using ::std::sin;
210
211 x = _T2(r * cos(theta));
212 y = _T2(r * sin(theta));
213}
214
215/// Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi)
216/// Angles expressed in radians.
217template <typename _T1, typename _T2>
218void cartesianToSpherical(const _T1 x, const _T1 y, const _T1 z, _T2& r, _T2& theta, _T2& phi)
219{
220 using ::std::acos;
221 using ::std::atan2;
222 using ::std::sqrt;
223
224 r = sqrt(x * x + y * y + z * z);
225 theta = acos(z / r);
226 phi = atan2(y, x);
227}
228
229/// Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates.
230/// Angles expressed in radians.
231template <typename _T1, typename _T2>
232void sphericalToCartesian(const _T1 r, const _T1 theta, const _T1 phi, _T2& x, _T2& y, _T2& z)
233{
234 using ::std::cos;
235 using ::std::sin;
236
237 x = r * sin(theta) * cos(phi);
238 y = r * sin(theta) * sin(phi);
239 z = r * cos(theta);
240}
241
242PACPUSTOOLS_API QMatrix4x4 yprenuToMatrix(QVector3D angle, QVector3D position);
243
244} // namespace Geodesy
245
246namespace Geodesie
247{
248using namespace Geodesy;
249} // namespace Geodesie
250
251#ifdef _MSC_VER
252# pragma warning(pop)
253#endif // _MSC_VER
254
255#endif // GEODESIE_H
Note: See TracBrowser for help on using the repository browser.