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

Last change on this file was 330, checked in by DHERBOMEZ Gérald, 10 years ago

change of backslash by slash

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