Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
LocalConversion.h
1 //
2 // LocalConversion.h
3 //
4 // This library has a concept of current conversion from earth to world
5 // coordinates which is represented by the vtLocalConversion class.
6 //
7 // Copyright (c) 2001-2009 Virtual Terrain Project
8 // Free for all uses, see license.txt for details.
9 //
10 
11 #ifndef VTLIB_LOCALCONVERSIONH
12 #define VTLIB_LOCALCONVERSIONH
13 
14 // global conversion factor
15 #define WORLD_SCALE 1.0f // 1 meter = 1.0 units
16 
17 #include "Projections.h" // for LinearUnits
18 
26 {
27 public:
29 
30  void Setup(LinearUnits units, const DRECT &earthextents);
31  void SetOrigin(const DPoint2 &origin);
32 
33  void convert_earth_to_local_xz(double ex, double ey, float &x, float &z) const;
34  void convert_local_xz_to_earth(float x, float z, double &ex, double &ey) const;
35 
36  void ConvertToEarth(const FPoint3 &world, DPoint3 &earth) const;
37  void ConvertToEarth(float x, float z, DPoint2 &earth) const;
38 
39  void ConvertFromEarth(const DPoint2 &earth, float &x, float &z) const;
40  void ConvertFromEarth(const DPoint3 &earth, FPoint3 &world) const;
41  void ConvertFromEarth(const DRECT &earth, FRECT &world) const;
42 
43  void ConvertVectorToEarth(float x, float z, DPoint2 &earth) const;
44  void ConvertVectorFromEarth(const DPoint2 &earth, float &x, float &z) const;
45 
46  LinearUnits GetUnits() const { return m_units; }
47 
48 protected:
49  LinearUnits m_units;
50  DPoint2 m_EarthOrigin;
51  DPoint2 m_scale;
52 };
53 
54 extern vtLocalConversion g_Conv;
55 
56 #endif // VTLIB_LOCALCONVERSIONH
57