source: pacpusframework/branches/0.0.x/include/Pacpus/PacpusTools/geodesie.h@ 237

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

Added: PacpusException - base class for all exceptions. DbiteExceptions inherits from it.
Added: PacpusLibConfig.h - dllimport/dllexport clauses separated from pacpus.h.
Update: comments.

  • 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 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
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 longitudeDegrees, double latitudeDegrees, double * heightMetersWgs84) 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.
133void Geographique_2_ECEF(double longitude, double latitude, double he, double& x, double& y, double& z);
134/// Convert from ECEF two ENU.
135/// @param[in] lon0 Longitude of the origin in radian.
136/// @param[in] lat0 Latitude of the origin in radian.
137/// @param[in] he0 Height of the origin in radian.
138void ECEF_2_ENU(double x,double y,double z,double& e,double& n,double& u,double lon0,double lat0,double he0);
139////////////////////////////////////////////////////////////////////////
140
141///ALGO0001
142/// @todo Rename
143double LatitueIsometrique(double latitude,double e);
144///ALGO0002
145/// @todo Rename
146double LatitueIsometrique2Lat(double latitude_iso,double e,double epsilon);
147
148///ALGO0003
149void Geo2ProjLambert(
150 double lambda,double phi,
151 double n, double c,double e,
152 double lambdac,double xs,double ys,
153 double& X,double& Y);
154///ALGO0004
155void Proj2GeoLambert(
156 double X,double Y,
157 double n, double c,double e,
158 double lambdac,double xs,double ys,
159 double epsilon,
160 double& lambda,double& phi);
161
162double ConvMerApp(double longitude);
163
164/// Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
165template <typename _T1, typename _T2>
166void cartesianToPolar(const _T1 x, const _T1 y, _T2 & r, _T2 & theta) {
167 r = std::sqrt(x*x + y*y);
168 theta = std::atan2(x, y);
169}
170
171/// Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
172template <typename _T1, typename _T2>
173void polarToCartesian(const _T1 r, const _T1 theta, _T2 & x, _T2 & y) {
174 x = r * std::cos(theta);
175 y = r * std::sin(theta);
176}
177
178/// Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi)
179/// Angles expressed in radians.
180template <typename _T1, typename _T2>
181void cartesianToSpherical(const _T1 x, const _T1 y, const _T1 z, _T2 & r, _T2 & theta, _T2 & phi) {
182 r = std::sqrt(x*x + y*y + z*z);
183 theta = std::acos(z / r);
184 phi = std::atan2(y, x);
185}
186
187/// Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates.
188/// Angles expressed in radians.
189template <typename _T1, typename _T2>
190void sphericalToCartesian(const _T1 r, const _T1 theta, const _T1 phi, _T2 & x, _T2 & y, _T2 & z) {
191 x = r * std::sin(theta) * std::cos(phi);
192 y = r * std::sin(theta) * std::sin(phi);
193 z = r * std::cos(theta);
194}
195
196} // namespace Geodesie
197
198#endif // GEODESIE_H
Note: See TracBrowser for help on using the repository browser.