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

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

Geodesie: formatting.

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