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

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

Documentation: file info.

  • Property svn:keywords set to Id
File size: 5.5 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 66 2013-01-09 16:54:11Z 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////////////////////////////////////////////////////////////////////////
33struct Matrice {
34 Matrice(const Matrice & A);
35 Matrice();
36 void Apply(double v0, double v1, double v2, double & Mv0, double & Mv1, double & Mv2);
37 double c0_l0;double c1_l0;double c2_l0;
38 double c0_l1;double c1_l1;double c2_l1;
39 double c0_l2;double c1_l2;double c2_l2;
40}; // class
41
42Matrice TransMat(const Matrice A);
43
44Matrice ProdMat(const Matrice A,const Matrice B);
45void Write(const Matrice A,std::ostream& out);
46
47////////////////////////////////////////////////////////////////////////
48class Raf98 {
49private :
50 std::vector<double> m_dvalues;
51 double LitGrille(unsigned int c,unsigned int l) const;
52public :
53 ~Raf98();
54 Raf98() {}
55 bool Load(const std::string & s);
56 bool Interpol(double longitude/*deg*/, double latitude/*deg*/, double* Hwgs84) const;
57}; // class
58////////////////////////////////////////////////////////////////////////
59
60////////////////////////////////////////////////////////////////////////
61inline double Deg2Rad(double deg) {return deg*M_PI/180.0;}
62inline double Rad2Deg(double rad) {return rad*180.0/M_PI;}
63////////////////////////////////////////////////////////////////////////
64
65const double a_Lambert93=6378137;
66const double f_Lambert93=1 / 298.257222101;
67const double e_Lambert93=sqrt(f_Lambert93*(2-f_Lambert93));
68const double lambda0_Lambert93=Deg2Rad(3.0);//degres
69const double phi0_Lambert93=Deg2Rad(46.5);
70const double phi1_Lambert93=Deg2Rad(44.0);
71const double phi2_Lambert93=Deg2Rad(49.0);//degres
72const double X0_Lambert93=700000;//
73const double Y0_Lambert93=6600000;//
74const double n_Lambert93 = 0.7256077650;
75const double c_Lambert93 = 11754255.426;
76const double xs_Lambert93 = 700000;
77const double ys_Lambert93 = 12655612.050;
78
79const double GRS_a = 6378137;
80const double GRS_f = 1/298.257222101;
81const double GRS_b = GRS_a*(1-GRS_f);
82const double GRS_e = sqrt((pow(GRS_a,2) - pow(GRS_b,2)) / pow(GRS_a,2));
83
84////////////////////////////////////////////////////////////////////////
85void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,Matrice in,double& E,double& N,double& h,Matrice& out);
86void Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,double& E,double& N,double& h);
87void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,double& lambda,double& phi,double& he);
88void Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,Matrice in,double& lambda,double& phi,double& he,Matrice& out);
89/** Convert from geographique to ECEF.
90 * @param[in] longitude Longitude in radian.
91 * @param[in] latitude Latitude in radian.
92 * @param[in] he Height in meter.
93 */
94void Geographique_2_ECEF(double longitude, double latitude, double he, double& x, double& y, double& z);
95/** Convert from ECEF two ENU.
96 * @param[in] lon0 Longitude of the origin in radian.
97 * @param[in] lat0 Latitude of the origin in radian.
98 * @param[in] he0 Height of the origin in radian.
99 */
100void ECEF_2_ENU(double x,double y,double z,double& e,double& n,double& u,double lon0,double lat0,double he0);
101////////////////////////////////////////////////////////////////////////
102
103//ALGO0001
104double LatitueIsometrique(double latitude,double e);
105//ALGO0002
106double LatitueIsometrique2Lat(double latitude_iso,double e,double epsilon);
107
108//ALGO0003
109void Geo2ProjLambert(
110 double lambda,double phi,
111 double n, double c,double e,
112 double lambdac,double xs,double ys,
113 double& X,double& Y);
114//ALGO0004
115void Proj2GeoLambert(
116 double X,double Y,
117 double n, double c,double e,
118 double lambdac,double xs,double ys,
119 double epsilon,
120 double& lambda,double& phi);
121
122double ConvMerApp(double longitude);
123
124/**
125Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
126*/
127template <typename _T1, typename _T2>
128void cartesianToPolar(const _T1 x, const _T1 y, _T2 & r, _T2 & theta) {
129 r = std::sqrt(x*x + y*y);
130 theta = std::atan2(x, y);
131}
132
133/**
134Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
135*/
136template <typename _T1, typename _T2>
137void polarToCartesian(const _T1 r, const _T1 theta, _T2 & x, _T2 & y) {
138 x = r * std::cos(theta);
139 y = r * std::sin(theta);
140}
141
142/**
143Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi)
144Angles expressed in radians.
145*/
146template <typename _T1, typename _T2>
147void cartesianToSpherical(const _T1 x, const _T1 y, const _T1 z, _T2 & r, _T2 & theta, _T2 & phi) {
148 r = std::sqrt(x*x + y*y + z*z);
149 theta = std::acos(z / r);
150 phi = std::atan2(y, x);
151}
152
153/**
154Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates.
155Angles expressed in radians.
156*/
157template <typename _T1, typename _T2>
158void sphericalToCartesian(const _T1 r, const _T1 theta, const _T1 phi, _T2 & x, _T2 & y, _T2 & z) {
159 x = r * std::sin(theta) * std::cos(phi);
160 y = r * std::sin(theta) * std::sin(phi);
161 z = r * std::cos(theta);
162}
163
164} // namespace Geodesie
165
166#endif // GEODESIE_H
Note: See TracBrowser for help on using the repository browser.