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

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

Update: using directive.

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