VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
coordSystem.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1996-2005 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: coordSystem.h,v $ $Revision: 1.30 $ $State: Exp $
7 *********************************************************************/
8 #ifndef coordSystem_H_
9 #define coordSystem_H_
10 
11 //
12 // \file coordSystem.h Contains the base (Geocentric, aka DIS) coordinate system class declaration.
13 //
14 
16 #include <matrix/vlMath.h>
17 #include <matrix/utmCoord.h>
18 #include <vl/utmView.h>
19 #include "geometry/extent.h"
20 #include <memory>
21 #include <vlutil/vlMutex.h>
22 #include <vlutil/vlScopedLock.h>
23 
24 #define GETLAT(dms) ((dms).lat())
25 #define GETLON(dms) ((dms).lon())
26 #define GETALT(dms) ((dms).alt())
27 #define SETLAT(dms,l) ((dms).setLat((l)))
28 #define SETLON(dms,l) ((dms).setLon((l)))
29 #define SETALT(dms,a) ((dms).setAlt((a)))
30 
31 #define DtSQR(x) ((x)*(x))
32 
33 namespace MAKVRinTerra { class DtProj; }
34 
35 enum CS_Type {
42  CS_FLATEARTH, // Add future CS_Types after this one.
43  CS_BCI210=50331650 // this is a specific coordinate system for BCI
44 };
45 
46 // Coordinate_System is the base class for converting between DIS
47 // (geocentric) and local (DB) coordinates. Coordinates are WGS84
48 // geocentric Cartesian coordinate (GCC) systems. Rotations are
49 // defined as right-handed rotations about Z, then Y, then X and DIS
50 // body coordinates are defined as X front, Y right, Z down.
51 // Rotations transform between DIS body and DIS world.
52 //
53 // All derived classes convert between their own system and the DIS system
55 {
56 public:
57  class ProjData;
58 
59  // Constructor
60  explicit Coordinate_System(bool setUseDynamicSceneOrigin = false,
61  double dynamicSceneOriginDeadband = 0.0);
62 
63  // Copy constructor
65 
66  // Destructor
67  virtual ~Coordinate_System();
68 
69  // Assignment operator
70  Coordinate_System& operator=(const Coordinate_System& orig);
71 
72  // Clone operator
73  virtual Coordinate_System* clone() const;
74 
75  virtual void dis2local(const DtVector& in, DtVector& out) const;
76 
77  virtual void dis2local(const DtDcm& in, DtDcm& out) const;
78 
79  virtual void dis2local(const DtVector& vIn, const DtDcm& dIn,
80  DtVector& vOut, DtDcm& dOut) const;
81 
82  virtual void disBody2localBody(const DtVector& in, DtVector& out) const;
83 
84  virtual void disBody2localBody(const DtDcm& in, DtDcm& out) const;
85 
86  virtual void local2dis(const DtVector& in, DtVector& out) const;
87 
88  virtual void local2dis(const DtDcm& in, DtDcm& out) const;
89 
90  virtual void local2dis(const DtVector& vIn, const DtDcm& dIn,
91  DtVector& vOut, DtDcm& dOut) const;
92 
93  virtual void localBody2disBody(const DtVector& in, DtVector& out) const;
94 
95  virtual void localBody2disBody(const DtDcm& in, DtDcm& out) const;
96 
97  // Returns the geodetic coordinate for a given local position.
98  virtual void localToGeodetic(const DtVector& localPosition,
99  DtGeodeticCoord& geodeticPosition) const;
100  virtual void localToGeodetic(const DtVector& localPosition,
101  DtVector& geodeticPosition) const;
102 
103  // Returns the local coordinate for a given geodetic position.
104  virtual void geodeticToLocal(const DtGeodeticCoord& geodeticPosition,
105  DtVector& localPosition) const;
106 
107  virtual void geodeticToLocal(const DtVector& geodeticPosition,
108  DtVector& localPosition) const;
109 
110  // \return A rotation matrices for going between topo and local coordinates,
111  // at a given local position. It is up to the caller to ensure that
112  // topoToLocal and localToTopo are valid pointers.
113  virtual void topoToLocal(const DtVector& localPosition, DtDcm& topoToLocal) const;
114  virtual void localToTopo(const DtVector& localPosition, DtDcm& localToTopo) const;
115 
116  // \return The unit vector pointing down (along the direction
117  // of gravity) at a given local position.
118  virtual DtVector down(const DtVector& localPosition) const;
119 
120  virtual DtDegMinSec latitudeOrigin() const;
121 
122  virtual DtDegMinSec longitudeOrigin() const;
123 
124  virtual CS_Type getCS_Type() const;
125 
126  virtual bool isSameCS(const Coordinate_System* CSystem) const;
127 
128  // Reset the origin of the scene
129  virtual void updateDynamicSceneOrigin(const DtVector& New_Origin);
130 
131  // Convert the CIG value to scene value by compensating for the
132  // scene origin offset.
133  virtual void Cig2Scene(const DtVector& Cig, DtVector& Scene) const;
134 
135  // Convert the scene value to CIG value by compensating for the
136  // scene origin offset.
137  virtual void Scene2Cig(const DtVector& Scene, DtVector& Cig) const;
138 
139  // Returns true if the scene origin was updated during this frame,
140  // false otherwise. If the scene origin was updated, previous
141  // local coordinate values will have to be updated.
142  virtual bool sceneOriginUpdatedThisFrame();
143 
144  // Returns the current scene origin in Cig coordinates.
145  virtual void sceneOrigin(DtVector& origin) const;
146 
147  // @return True if dynamic scene origin is in affect.
148  virtual bool useDynamicSceneOrigin();
149 
150  virtual void localToGeodetic(const DtExtent& extent, DtExtent& destExtent) const;
151  virtual void geodeticToLocal(const DtExtent& extent, DtExtent& destExtent) const;
152 
153  virtual void local2dis(const DtExtent& extent, DtExtent& destExtent) const;
154  virtual void dis2local(const DtExtent& extent, DtExtent& destExtent) const;
155 
156  // Returns name of coordinate system
157  virtual DtString coordinateSystemName() const;
158 
159  // Sets the new lat/lon for the origin of the coordinate system
160  virtual void setOrigin(const DtGeodeticCoord&);
161  virtual DtGeodeticCoord origin() const;
162 
163  // This class allows VRIT to attach proj data to this CS so we don't have to
164  // add new code to MTTK which is a pain to test and update.
166  public:
167  virtual const MAKVRinTerra::DtProj* proj() const = 0;
168  virtual std::auto_ptr<ProjData> clone() const = 0;
169  virtual ~ProjData();
170  };
171 
172  // Allows thread-safe access to internal ProjData object.
174  public:
176  : myCS(cs), myLock(cs->myProjMutex) { }
177 
178  const MAKVRinTerra::DtProj* get() const {
179  return myCS->myProjData.get() ? myCS->myProjData->proj() : 0;
180  }
181 
182  void set(std::auto_ptr<ProjData> p) {
183  myCS->myProjData = p;
184  }
185 
186  private:
188  DtScopedLock myLock;
189  };
190 
191 protected:
192  DtDegMinSec myLatitudeOrigin;
193  DtDegMinSec myLongitudeOrigin;
200 
201  // access controled by ProjAccess
202  friend class ProjAccess;
203  mutable DtMutex myProjMutex;
204  std::auto_ptr<ProjData> myProjData;
205 };
206 
207 #endif
DtDegMinSec myLatitudeOrigin
Definition: coordSystem.h:192
void set(std::auto_ptr< ProjData > p)
Definition: coordSystem.h:182
boost::shared_ptr< ProjData > myProjData
Definition: proj.h:210
voidpf uLong int origin
Definition: ioapi.h:42
DtDegMinSec myLongitudeOrigin
Definition: coordSystem.h:193
DtVector myScenePosition
Definition: coordSystem.h:198
bool myDynamicSceneOriginInAffect
Definition: coordSystem.h:195
Definition: coordSystem.h:41
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
Definition: coordSystem.h:37
DtScopedLock myLock
Definition: coordSystem.h:188
Definition: coordSystem.h:54
Represents some coordinate system. The terms &quot;coordinate system&quot;, &quot;projection&quot;, &quot;spatial reference&quot;...
Definition: proj.h:44
bool myDynamicSceneOriginUpdatedThisFrame
Definition: coordSystem.h:196
Definition: coordSystem.h:43
Definition: coordSystem.h:39
Definition: coordSystem.h:40
CS_Type myCoordinateSystemType
Definition: coordSystem.h:194
ProjAccess(Coordinate_System *cs)
Definition: coordSystem.h:175
Definition: coordSystem.h:42
Definition: coordSystem.h:36
CS_Type
Definition: coordSystem.h:35
Contains the declaration of the DtExtent class.
bool myInitialized
Definition: coordSystem.h:197
Definition: coordSystem.h:38
Definition: coordSystem.h:173
#define DT_DLL_terrainCS
Definition: terrainCSDefines.h:23
Coordinate_System * myCS
Definition: coordSystem.h:187
std::auto_ptr< ProjData > myProjData
Definition: coordSystem.h:204
Definition: coordSystem.h:165
DtMutex myProjMutex
Definition: coordSystem.h:203
double myDynamicSceneOriginDeadbandRegion
Definition: coordSystem.h:199

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)