source: pacpusframework/branches/2.0-beta1/include/Pacpus/PacpusTools/geodesie.h@ 139

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

Update: added dll export/import macros for PacpusTools.

  • Property svn:executable set to *
File size: 6.6 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 Firstname Surname <firstname.surname@utc.fr>
7/// @date Month, Year
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 PACPUS_TOOLS_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
73Matrice TransMat(const Matrice A);
74
75Matrice ProdMat(const Matrice A,const Matrice B);
76void Write(const Matrice A,std::ostream& out);
77
78////////////////////////////////////////////////////////////////////////
79/// @todo Documentation
80class PACPUS_TOOLS_API Raf98
81{
82public:
83 /// Ctor of Raf98 class.
84 Raf98() {}
85 /// Dtor of Raf98 class.
86 ~Raf98();
87
88 /// @todo Documentation
89 /// @param s filepath
90 bool Load(const std::string & s);
91
92 /// @todo Documentation
93 /// @param longitude [degrees]
94 /// @param latitude [degrees]
95 /// @param Hwgs84 Output: interpolated altitude using WGS84 geoid model [meters]
96 bool Interpol(double longitude/*deg*/, double latitude/*deg*/, double* Hwgs84) const;
97
98private:
99 std::vector<double> m_dvalues;
100 double LitGrille(unsigned int c,unsigned int l) const;
101};
102
103////////////////////////////////////////////////////////////////////////
104
105////////////////////////////////////////////////////////////////////////
106inline double Deg2Rad(double deg) {return deg*M_PI/180.0;}
107inline double Rad2Deg(double rad) {return rad*180.0/M_PI;}
108////////////////////////////////////////////////////////////////////////
109
110const double a_Lambert93=6378137;
111const double f_Lambert93=1 / 298.257222101;
112const double e_Lambert93=sqrt(f_Lambert93*(2-f_Lambert93));
113const double lambda0_Lambert93=Deg2Rad(3.0);//degres
114const double phi0_Lambert93=Deg2Rad(46.5);
115const double phi1_Lambert93=Deg2Rad(44.0);
116const double phi2_Lambert93=Deg2Rad(49.0);//degres
117const double X0_Lambert93=700000;//
118const double Y0_Lambert93=6600000;//
119const double n_Lambert93 = 0.7256077650;
120const double c_Lambert93 = 11754255.426;
121const double xs_Lambert93 = 700000;
122const double ys_Lambert93 = 12655612.050;
123
124const double GRS_a = 6378137;
125const double GRS_f = 1/298.257222101;
126const double GRS_b = GRS_a*(1-GRS_f);
127const double GRS_e = sqrt((pow(GRS_a,2) - pow(GRS_b,2)) / pow(GRS_a,2));
128
129////////////////////////////////////////////////////////////////////////
130void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,Matrice in,double& E,double& N,double& h,Matrice& out);
131void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,double& E,double& N,double& h);
132void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,double& lambda,double& phi,double& he);
133void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,Matrice in,double& lambda,double& phi,double& he,Matrice& out);
134/** Convert from geographique to ECEF.
135 * @param[in] longitude Longitude in radian.
136 * @param[in] latitude Latitude in radian.
137 * @param[in] he Height in meter.
138 */
139void 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.
144 */
145void ECEF_2_ENU(double x,double y,double z,double& e,double& n,double& u,double lon0,double lat0,double he0);
146////////////////////////////////////////////////////////////////////////
147
148///ALGO0001
149/// @todo Rename
150double LatitueIsometrique(double latitude,double e);
151///ALGO0002
152/// @todo Rename
153double LatitueIsometrique2Lat(double latitude_iso,double e,double epsilon);
154
155///ALGO0003
156void Geo2ProjLambert(
157 double lambda,double phi,
158 double n, double c,double e,
159 double lambdac,double xs,double ys,
160 double& X,double& Y);
161///ALGO0004
162void Proj2GeoLambert(
163 double X,double Y,
164 double n, double c,double e,
165 double lambdac,double xs,double ys,
166 double epsilon,
167 double& lambda,double& phi);
168
169double ConvMerApp(double longitude);
170
171/**
172Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
173*/
174template <typename _T1, typename _T2>
175void cartesianToPolar(const _T1 x, const _T1 y, _T2 & r, _T2 & theta) {
176 r = std::sqrt(x*x + y*y);
177 theta = std::atan2(x, y);
178}
179
180/**
181Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
182*/
183template <typename _T1, typename _T2>
184void polarToCartesian(const _T1 r, const _T1 theta, _T2 & x, _T2 & y) {
185 x = r * std::cos(theta);
186 y = r * std::sin(theta);
187}
188
189/**
190Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi)
191Angles expressed in radians.
192*/
193template <typename _T1, typename _T2>
194void cartesianToSpherical(const _T1 x, const _T1 y, const _T1 z, _T2 & r, _T2 & theta, _T2 & phi) {
195 r = std::sqrt(x*x + y*y + z*z);
196 theta = std::acos(z / r);
197 phi = std::atan2(y, x);
198}
199
200/**
201Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates.
202Angles expressed in radians.
203*/
204template <typename _T1, typename _T2>
205void sphericalToCartesian(const _T1 r, const _T1 theta, const _T1 phi, _T2 & x, _T2 & y, _T2 & z) {
206 x = r * std::sin(theta) * std::cos(phi);
207 y = r * std::sin(theta) * std::sin(phi);
208 z = r * std::cos(theta);
209}
210
211QMatrix4x4 yprenuToMatrix(QVector3D angle, QVector3D position);
212
213} // namespace Geodesie
214
215#endif // GEODESIE_H
Note: See TracBrowser for help on using the repository browser.