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

Last change on this file since 91 was 91, checked in by DHERBOMEZ Gérald, 11 years ago

Improvement of the build system to avoid some workarounds

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