source: pacpusframework/branches/0.1.x/include/Pacpus/PacpusTools/geodesie.h@ 247

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

Update: merged changes from trunk.

  • Property svn:executable set to *
File size: 6.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 Jean Laneurit <firstname.surname@utc.fr>
7/// @date April, 2010
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
21#include <QMatrix4x4>
22#include <QVector3D>
23
24#include "PacpusToolsConfig.h"
25
26namespace 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!
42struct PACPUSTOOLS_API Matrice
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
73PACPUSTOOLS_API Matrice TransMat(const Matrice A);
74PACPUSTOOLS_API Matrice ProdMat(const Matrice A,const Matrice B);
75PACPUSTOOLS_API void Write(const Matrice A,std::ostream& out);
76
77////////////////////////////////////////////////////////////////////////
78/// @todo Documentation
79class PACPUSTOOLS_API Raf98
80{
81public:
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
97private:
98 std::vector<double> m_dvalues;
99 double LitGrille(unsigned int c,unsigned int l) const;
100};
101
102////////////////////////////////////////////////////////////////////////
103
104////////////////////////////////////////////////////////////////////////
105inline double Deg2Rad(double deg)
106{
107 return deg*M_PI/180.0;
108}
109
110inline double Rad2Deg(double rad)
111{
112 return rad*180.0/M_PI;
113}
114
115////////////////////////////////////////////////////////////////////////
116
117const double a_Lambert93=6378137;
118const double f_Lambert93=1 / 298.257222101;
119const double e_Lambert93=sqrt(f_Lambert93*(2-f_Lambert93));
120const double lambda0_Lambert93=Deg2Rad(3.0);//degres
121const double phi0_Lambert93=Deg2Rad(46.5);
122const double phi1_Lambert93=Deg2Rad(44.0);
123const double phi2_Lambert93=Deg2Rad(49.0);//degres
124const double X0_Lambert93=700000;//
125const double Y0_Lambert93=6600000;//
126const double n_Lambert93 = 0.7256077650;
127const double c_Lambert93 = 11754255.426;
128const double xs_Lambert93 = 700000;
129const double ys_Lambert93 = 12655612.050;
130
131const double GRS_a = 6378137;
132const double GRS_f = 1/298.257222101;
133const double GRS_b = GRS_a*(1-GRS_f);
134const double GRS_e = sqrt((pow(GRS_a,2) - pow(GRS_b,2)) / pow(GRS_a,2));
135
136////////////////////////////////////////////////////////////////////////
137PACPUSTOOLS_API void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,Matrice in,double& E,double& N,double& h,Matrice& out);
138PACPUSTOOLS_API void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,double& E,double& N,double& h);
139PACPUSTOOLS_API void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,double& lambda,double& phi,double& he);
140PACPUSTOOLS_API void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,Matrice in,double& lambda,double& phi,double& he,Matrice& out);
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 */
146PACPUSTOOLS_API void Geographique_2_ECEF(double longitude, double latitude, double he, double& x, double& y, double& z);
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 */
152PACPUSTOOLS_API void ECEF_2_ENU(double x,double y,double z,double& e,double& n,double& u,double lon0,double lat0,double he0);
153////////////////////////////////////////////////////////////////////////
154
155///ALGO0001
156/// @todo Rename
157PACPUSTOOLS_API double LatitueIsometrique(double latitude,double e);
158///ALGO0002
159/// @todo Rename
160PACPUSTOOLS_API double LatitueIsometrique2Lat(double latitude_iso,double e,double epsilon);
161
162///ALGO0003
163PACPUSTOOLS_API void Geo2ProjLambert(
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
169PACPUSTOOLS_API void Proj2GeoLambert(
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
176PACPUSTOOLS_API double ConvMerApp(double longitude);
177
178/**
179Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
180*/
181template <typename _T1, typename _T2>
182void 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/**
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 x = r * std::cos(theta);
193 y = r * std::sin(theta);
194}
195
196/**
197Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi)
198Angles expressed in radians.
199*/
200template <typename _T1, typename _T2>
201void 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/**
208Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates.
209Angles expressed in radians.
210*/
211template <typename _T1, typename _T2>
212void 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
218PACPUSTOOLS_API QMatrix4x4 yprenuToMatrix(QVector3D angle, QVector3D position);
219
220} // namespace Geodesie
221
222#endif // GEODESIE_H
Note: See TracBrowser for help on using the repository browser.