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

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

Added: more documentation.

  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1// This file is part of the PACPUS framework distributed under the
2// CECILL-C License, Version 1.0.
3//
4/// @file
5/// @author Firstname Surname <firstname.surname@utc.fr>
6/// @date Month, Year
7/// @version $Id: geodesie.h 69 2013-01-09 23:04:42Z kurdejma $
8/// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
9/// @brief Brief description.
10///
11/// Detailed description.
12
13#ifndef GEODESIE_H
14#define GEODESIE_H
15
16#include <cmath>
17#include <iostream>
18#include <vector>
19
20namespace Geodesie {
21
22#ifndef M_PI
23# define M_PI 3.14159265358979323846
24#endif
25#ifndef M_PI_2
26# define M_PI_2 1.57079632679489661923
27#endif
28#ifndef M_PI_4
29# define M_PI_4 0.78539816339744830962
30#endif
31
32////////////////////////////////////////////////////////////////////////
33/// 9x9 matrix ???
34///
35/// @todo Documentation
36/// @todo Rewrite!
37struct Matrice
38{
39 Matrice(const Matrice & A);
40 Matrice();
41 void Apply(double v0, double v1, double v2, double & Mv0, double & Mv1, double & Mv2);
42
43 double c0_l0;double c1_l0;double c2_l0;
44 double c0_l1;double c1_l1;double c2_l1;
45 double c0_l2;double c1_l2;double c2_l2;
46};
47
48Matrice TransMat(const Matrice A);
49
50Matrice ProdMat(const Matrice A,const Matrice B);
51void Write(const Matrice A,std::ostream& out);
52
53////////////////////////////////////////////////////////////////////////
54/// @todo Documentation
55class Raf98
56{
57public:
58 /// Ctor of Raf98 class.
59 Raf98() {}
60 /// Dtor of Raf98 class.
61 ~Raf98();
62
63 /// @todo Documentation
64 /// @param s filepath
65 bool Load(const std::string & s);
66
67 /// @todo Documentation
68 /// @param longitude [degrees]
69 /// @param latitude [degrees]
70 /// @param Hwgs84 Output: interpolated altitude using WGS84 geoid model [meters]
71 bool Interpol(double longitude/*deg*/, double latitude/*deg*/, double* Hwgs84) const;
72
73private:
74 std::vector<double> m_dvalues;
75 double LitGrille(unsigned int c,unsigned int l) const;
76};
77
78////////////////////////////////////////////////////////////////////////
79
80////////////////////////////////////////////////////////////////////////
81inline double Deg2Rad(double deg) {return deg*M_PI/180.0;}
82inline double Rad2Deg(double rad) {return rad*180.0/M_PI;}
83////////////////////////////////////////////////////////////////////////
84
85const double a_Lambert93=6378137;
86const double f_Lambert93=1 / 298.257222101;
87const double e_Lambert93=sqrt(f_Lambert93*(2-f_Lambert93));
88const double lambda0_Lambert93=Deg2Rad(3.0);//degres
89const double phi0_Lambert93=Deg2Rad(46.5);
90const double phi1_Lambert93=Deg2Rad(44.0);
91const double phi2_Lambert93=Deg2Rad(49.0);//degres
92const double X0_Lambert93=700000;//
93const double Y0_Lambert93=6600000;//
94const double n_Lambert93 = 0.7256077650;
95const double c_Lambert93 = 11754255.426;
96const double xs_Lambert93 = 700000;
97const double ys_Lambert93 = 12655612.050;
98
99const double GRS_a = 6378137;
100const double GRS_f = 1/298.257222101;
101const double GRS_b = GRS_a*(1-GRS_f);
102const double GRS_e = sqrt((pow(GRS_a,2) - pow(GRS_b,2)) / pow(GRS_a,2));
103
104////////////////////////////////////////////////////////////////////////
105void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,Matrice in,double& E,double& N,double& h,Matrice& out);
106void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,double& E,double& N,double& h);
107void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,double& lambda,double& phi,double& he);
108void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,Matrice in,double& lambda,double& phi,double& he,Matrice& out);
109/** Convert from geographique to ECEF.
110 * @param[in] longitude Longitude in radian.
111 * @param[in] latitude Latitude in radian.
112 * @param[in] he Height in meter.
113 */
114void Geographique_2_ECEF(double longitude, double latitude, double he, double& x, double& y, double& z);
115/** Convert from ECEF two ENU.
116 * @param[in] lon0 Longitude of the origin in radian.
117 * @param[in] lat0 Latitude of the origin in radian.
118 * @param[in] he0 Height of the origin in radian.
119 */
120void ECEF_2_ENU(double x,double y,double z,double& e,double& n,double& u,double lon0,double lat0,double he0);
121////////////////////////////////////////////////////////////////////////
122
123///ALGO0001
124/// @todo Rename
125double LatitueIsometrique(double latitude,double e);
126///ALGO0002
127/// @todo Rename
128double LatitueIsometrique2Lat(double latitude_iso,double e,double epsilon);
129
130///ALGO0003
131void Geo2ProjLambert(
132 double lambda,double phi,
133 double n, double c,double e,
134 double lambdac,double xs,double ys,
135 double& X,double& Y);
136///ALGO0004
137void Proj2GeoLambert(
138 double X,double Y,
139 double n, double c,double e,
140 double lambdac,double xs,double ys,
141 double epsilon,
142 double& lambda,double& phi);
143
144double ConvMerApp(double longitude);
145
146/**
147Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
148*/
149template <typename _T1, typename _T2>
150void cartesianToPolar(const _T1 x, const _T1 y, _T2 & r, _T2 & theta) {
151 r = std::sqrt(x*x + y*y);
152 theta = std::atan2(x, y);
153}
154
155/**
156Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
157*/
158template <typename _T1, typename _T2>
159void polarToCartesian(const _T1 r, const _T1 theta, _T2 & x, _T2 & y) {
160 x = r * std::cos(theta);
161 y = r * std::sin(theta);
162}
163
164/**
165Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi)
166Angles expressed in radians.
167*/
168template <typename _T1, typename _T2>
169void cartesianToSpherical(const _T1 x, const _T1 y, const _T1 z, _T2 & r, _T2 & theta, _T2 & phi) {
170 r = std::sqrt(x*x + y*y + z*z);
171 theta = std::acos(z / r);
172 phi = std::atan2(y, x);
173}
174
175/**
176Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates.
177Angles expressed in radians.
178*/
179template <typename _T1, typename _T2>
180void sphericalToCartesian(const _T1 r, const _T1 theta, const _T1 phi, _T2 & x, _T2 & y, _T2 & z) {
181 x = r * std::sin(theta) * std::cos(phi);
182 y = r * std::sin(theta) * std::sin(phi);
183 z = r * std::cos(theta);
184}
185
186} // namespace Geodesie
187
188#endif // GEODESIE_H
Note: See TracBrowser for help on using the repository browser.