VR-Forces 4.0.4 Class Documentation
include/terrainCS/coordSystem.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 1996-2005 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: coordSystem.h,v $ $Revision: 1.30 $ $State: Exp $
00007 *********************************************************************/
00008 #ifndef coordSystem_H_
00009 #define coordSystem_H_
00010 
00011 //
00012 // \file coordSystem.h Contains the base (Geocentric, aka DIS) coordinate system class declaration.
00013 // 
00014 
00015 #include "terrainCS/terrainCSDefines.h"
00016 #include <matrix/vlMath.h>
00017 #include <matrix/utmCoord.h>
00018 #include <vl/utmView.h>
00019 #include "geometry/tdbextent.h"
00020 #include <memory>
00021 #include <vlutil/vlMutex.h>
00022 #include <vlutil/vlScopedLock.h>
00023 
00024 #define GETLAT(dms)     ((dms).lat())
00025 #define GETLON(dms)     ((dms).lon())
00026 #define GETALT(dms)     ((dms).alt())
00027 #define SETLAT(dms,l)   ((dms).setLat((l)))
00028 #define SETLON(dms,l)   ((dms).setLon((l)))
00029 #define SETALT(dms,a)   ((dms).setAlt((a)))
00030 
00031 #define DtSQR(x)    ((x)*(x))
00032 
00033 namespace MAKVRinTerra { class DtProj; }
00034 
00035 enum CS_Type {
00036    CS_NONE,
00037    CS_LCC, 
00038    CS_UTM, 
00039    CS_GEOD,
00040    CS_DIS, 
00041    CS_TCC,
00042    CS_FLATEARTH, // Add future CS_Types after this one.
00043    CS_BCI210=50331650 // this is a specific coordinate system for BCI
00044 };
00045 
00046 // Coordinate_System is the base class for converting between DIS
00047 // (geocentric) and local (DB) coordinates.  Coordinates are WGS84
00048 // geocentric Cartesian coordinate (GCC) systems.  Rotations are
00049 // defined as right-handed rotations about Z, then Y, then X and DIS
00050 // body coordinates are defined as X front, Y right, Z down.
00051 // Rotations transform between DIS body and DIS world.
00052 //
00053 // All derived classes convert between their own system and the DIS system
00054 class DT_DLL_terrainCS Coordinate_System
00055 {
00056 public:
00057    class ProjData;
00058 
00059    // Constructor
00060    Coordinate_System(bool setUseDynamicSceneOrigin = false, 
00061                      double dynamicSceneOriginDeadband = 0.0);
00062 
00063    // Copy constructor
00064    Coordinate_System(const Coordinate_System& orig);
00065 
00066    // Destructor
00067    virtual ~Coordinate_System();
00068 
00069    // Assignment operator
00070    Coordinate_System& operator=(const Coordinate_System& orig);
00071 
00072    // Clone operator
00073    virtual Coordinate_System* clone() const;
00074 
00075    virtual void dis2local(const DtVector& in, DtVector&  out) const;
00076 
00077    virtual void dis2local(const DtDcm& in, DtDcm& out) const;
00078 
00079    virtual void dis2local(const DtVector& vIn, const DtDcm& dIn,
00080       DtVector&  vOut, DtDcm& dOut) const;
00081 
00082    virtual void disBody2localBody(const DtVector& in, DtVector&  out) const;
00083 
00084    virtual void disBody2localBody(const DtDcm& in, DtDcm& out) const;
00085 
00086    virtual void local2dis(const DtVector& in, DtVector&  out) const;
00087 
00088    virtual void local2dis(const DtDcm& in, DtDcm& out) const;
00089 
00090    virtual void local2dis(const DtVector& vIn, const DtDcm& dIn,
00091       DtVector&  vOut, DtDcm& dOut) const;
00092 
00093    virtual void localBody2disBody(const DtVector& in, DtVector&  out) const;
00094 
00095    virtual void localBody2disBody(const DtDcm& in, DtDcm& out) const;
00096 
00097    // Returns the geodetic coordinate for a given local position.
00098    virtual void localToGeodetic(const DtVector& localPosition,
00099       DtGeodeticCoord& geodeticPosition) const;
00100    virtual void localToGeodetic(const DtVector& localPosition,
00101       DtVector& geodeticPosition) const;
00102 
00103    // Returns the local coordinate for a given geodetic position.
00104    virtual void geodeticToLocal(const DtGeodeticCoord& geodeticPosition,
00105       DtVector& localPosition) const;
00106    
00107    virtual void geodeticToLocal(const DtVector& geodeticPosition,
00108       DtVector& localPosition) const;
00109 
00110    // \return A rotation matrices for going between topo and local coordinates, 
00111    // at a given local position.  It is up to the caller to ensure that 
00112    // topoToLocal and localToTopo are valid pointers.
00113    virtual void topoToLocal(const DtVector& localPosition, DtDcm& topoToLocal) const;
00114    virtual void localToTopo(const DtVector& localPosition, DtDcm& localToTopo) const;
00115 
00116    // \return The unit vector pointing down (along the direction
00117    // of gravity) at a given local position.
00118    virtual DtVector down(const DtVector& localPosition) const;
00119 
00120    virtual DtDegMinSec latitudeOrigin() const;
00121 
00122    virtual DtDegMinSec longitudeOrigin() const;
00123 
00124    virtual CS_Type getCS_Type() const;
00125 
00126    virtual bool isSameCS(const Coordinate_System* CSystem) const;
00127 
00128    // Reset the origin of the scene
00129    virtual void updateDynamicSceneOrigin(const DtVector& New_Origin);
00130 
00131    // Convert the CIG value to scene value by compensating for the
00132    // scene origin offset.
00133    virtual void Cig2Scene(const DtVector& Cig, DtVector&  Scene) const;
00134 
00135    // Convert the scene value to CIG value by compensating for the
00136    // scene origin offset.
00137    virtual void Scene2Cig(const DtVector& Scene, DtVector&  Cig) const;
00138 
00139    // Returns true if the scene origin was updated during this frame,
00140    // false otherwise.  If the scene origin was updated, previous
00141    // local coordinate values will have to be updated.
00142    virtual bool sceneOriginUpdatedThisFrame();
00143 
00144    // Returns the current scene origin in Cig coordinates.
00145    virtual void sceneOrigin(DtVector& origin) const;
00146 
00147    // @return True if dynamic scene origin is in affect.
00148    virtual bool useDynamicSceneOrigin();
00149 
00150    virtual void localToGeodetic(const DtExtent& extent, DtExtent& destExtent) const;
00151    virtual void geodeticToLocal(const DtExtent& extent, DtExtent& destExtent) const;
00152 
00153    virtual void local2dis(const DtExtent& extent, DtExtent& destExtent) const;
00154    virtual void dis2local(const DtExtent& extent, DtExtent& destExtent) const;
00155 
00156    // Returns name of coordinate system
00157    virtual DtString coordinateSystemName() const;
00158 
00159    // Sets the new lat/lon for the origin of the coordinate system
00160    virtual void setOrigin(const DtGeodeticCoord&);
00161    virtual DtGeodeticCoord origin() const;
00162 
00163    // This class allows VRIT to attach proj data to this CS so we don't have to
00164    // add new code to MTTK which is a pain to test and update.
00165    class DT_DLL_terrainCS ProjData {
00166    public:
00167       virtual const MAKVRinTerra::DtProj* proj() const = 0;
00168       virtual std::auto_ptr<ProjData> clone() const = 0;
00169       virtual ~ProjData();
00170    };
00171 
00172    // Allows thread-safe access to internal ProjData object.
00173    class DT_DLL_terrainCS ProjAccess {
00174    public:
00175       explicit ProjAccess(Coordinate_System* cs)
00176          : myCS(cs), myLock(cs->myProjMutex) { }
00177 
00178       const MAKVRinTerra::DtProj* get() const {
00179          return myCS->myProjData.get() ? myCS->myProjData->proj() : 0;
00180       }
00181 
00182       void set(std::auto_ptr<ProjData> p) {
00183          myCS->myProjData = p;
00184       }
00185 
00186    private:
00187       Coordinate_System* myCS;
00188       DtScopedLock myLock;
00189    };
00190 
00191 protected:
00192    DtDegMinSec myLatitudeOrigin;
00193    DtDegMinSec myLongitudeOrigin;
00194    CS_Type myCoordinateSystemType;
00195    bool myDynamicSceneOriginInAffect;
00196    bool myDynamicSceneOriginUpdatedThisFrame;
00197    bool myInitialized;
00198    DtVector myScenePosition;
00199    double myDynamicSceneOriginDeadbandRegion;
00200 
00201    // access controled by ProjAccess
00202    friend class ProjAccess;
00203    mutable DtMutex myProjMutex;
00204    std::auto_ptr<ProjData> myProjData;
00205 };
00206 
00207 #endif

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)