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

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

Minor fixes.

  • Property svn:executable set to *
File size: 7.0 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 "PacpusToolsConfig.h"
18
19//#include <boost/math/constants/constants.hpp>
20#include <cmath>
21#include <iostream>
22#include <vector>
23
24#include <QMatrix4x4>
25#include <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
74PACPUSTOOLS_API Matrice TransMat(const Matrice A);
75PACPUSTOOLS_API Matrice ProdMat(const Matrice A, const Matrice B);
76PACPUSTOOLS_API void Write(const Matrice A, std::ostream & out);
77
78////////////////////////////////////////////////////////////////////////
79/// @todo Documentation
80class PACPUSTOOLS_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)
107{
108 return deg * M_PI / 180.0;
109}
110
111inline double Rad2Deg(double rad)
112{
113 return rad * 180.0 / M_PI;
114}
115
116////////////////////////////////////////////////////////////////////////
117
118const double a_Lambert93=6378137;
119const double f_Lambert93=1 / 298.257222101;
120const double e_Lambert93=sqrt(f_Lambert93*(2-f_Lambert93));
121const double lambda0_Lambert93=Deg2Rad(3.0);//degres
122const double phi0_Lambert93=Deg2Rad(46.5);
123const double phi1_Lambert93=Deg2Rad(44.0);
124const double phi2_Lambert93=Deg2Rad(49.0);//degres
125const double X0_Lambert93=700000;//
126const double Y0_Lambert93=6600000;//
127const double n_Lambert93 = 0.7256077650;
128const double c_Lambert93 = 11754255.426;
129const double xs_Lambert93 = 700000;
130const double ys_Lambert93 = 12655612.050;
131
132const double GRS_a = 6378137;
133const double GRS_f = 1/298.257222101;
134const double GRS_b = GRS_a*(1-GRS_f);
135const double GRS_e = sqrt((pow(GRS_a,2) - pow(GRS_b,2)) / pow(GRS_a,2));
136
137////////////////////////////////////////////////////////////////////////
138PACPUSTOOLS_API void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,Matrice in,double& E,double& N,double& h,Matrice& out);
139PACPUSTOOLS_API void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,double& E,double& N,double& h);
140PACPUSTOOLS_API void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,double& lambda,double& phi,double& he);
141PACPUSTOOLS_API void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,Matrice in,double& lambda,double& phi,double& he,Matrice& out);
142/** Convert from geographique to ECEF.
143 * @param[in] longitude Longitude in radian.
144 * @param[in] latitude Latitude in radian.
145 * @param[in] he Height in meter.
146 */
147PACPUSTOOLS_API void Geographique_2_ECEF(double longitude, double latitude, double he, double& x, double& y, double& z);
148/** Convert from ECEF two ENU.
149 * @param[in] lon0 Longitude of the origin in radian.
150 * @param[in] lat0 Latitude of the origin in radian.
151 * @param[in] he0 Height of the origin in radian.
152 */
153PACPUSTOOLS_API void ECEF_2_ENU(double x,double y,double z,double& e,double& n,double& u,double lon0,double lat0,double he0);
154////////////////////////////////////////////////////////////////////////
155
156///ALGO0001
157/// @todo Rename
158PACPUSTOOLS_API double LatitueIsometrique(double latitude,double e);
159///ALGO0002
160/// @todo Rename
161PACPUSTOOLS_API double LatitueIsometrique2Lat(double latitude_iso,double e,double epsilon);
162
163///ALGO0003
164PACPUSTOOLS_API void Geo2ProjLambert(
165 double lambda,double phi,
166 double n, double c,double e,
167 double lambdac,double xs,double ys,
168 double& X,double& Y);
169///ALGO0004
170PACPUSTOOLS_API void Proj2GeoLambert(
171 double X,double Y,
172 double n, double c,double e,
173 double lambdac,double xs,double ys,
174 double epsilon,
175 double& lambda,double& phi);
176
177PACPUSTOOLS_API double ConvMerApp(double longitude);
178
179/**
180Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
181*/
182template <typename _T1, typename _T2>
183void cartesianToPolar(const _T1 x, const _T1 y, _T2 & r, _T2 & theta) {
184 r = std::sqrt(x*x + y*y);
185 theta = std::atan2(x, y);
186}
187
188/**
189Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
190*/
191template <typename _T1, typename _T2>
192void polarToCartesian(const _T1 r, const _T1 theta, _T2 & x, _T2 & y) {
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 r = std::sqrt(x*x + y*y + z*z);
204 theta = std::acos(z / r);
205 phi = std::atan2(y, x);
206}
207
208/**
209Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates.
210Angles expressed in radians.
211*/
212template <typename _T1, typename _T2>
213void sphericalToCartesian(const _T1 r, const _T1 theta, const _T1 phi, _T2 & x, _T2 & y, _T2 & z) {
214 x = r * std::sin(theta) * std::cos(phi);
215 y = r * std::sin(theta) * std::sin(phi);
216 z = r * std::cos(theta);
217}
218
219PACPUSTOOLS_API QMatrix4x4 yprenuToMatrix(QVector3D angle, QVector3D position);
220
221} // namespace Geodesie
222
223#endif // GEODESIE_H
Note: See TracBrowser for help on using the repository browser.