OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimEllipsoid.h
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Garrett Potts
6 //
7 // Description:
8 //
9 // This is the class declaration for ossimEllipsoid. Though valid for the
10 // general class of geometric shape, this implementation contains additional
11 // methods suited to the Earth ellipsoid.
12 //
13 //*******************************************************************
14 // $ID$
15 
16 #ifndef ossimEllipsoid_HEADER
17 #define ossimEllipsoid_HEADER 1
18 
19 #include <cmath> /* std::sqrt */
20 
22 #include <ossim/base/ossimCommon.h>
23 #include <ossim/base/ossimString.h>
24 #include <ossim/matrix/newmat.h>
25 
26 class ossimEcefRay;
27 class ossimEcefPoint;
28 class ossimEcefVector;
29 class ossimMatrix4x4;
30 class ossimKeywordlist;
31 class ossimDpt;
32 
33 /*!****************************************************************************
34  *
35  * CLASS: ossimEllipsoid
36  *
37  *****************************************************************************/
39 {
40 public:
41 
45  ossimEllipsoid(const ossimEllipsoid &ellipsoid);
46  ossimEllipsoid(const ossimString &name,
47  const ossimString &code,
48  const double &major_axis,
49  const double &minor_axis,
50  ossim_uint32 epsg_code=0);
51  ossimEllipsoid(const double &major_axis,
52  const double &minor_axis);
54 
55  virtual ~ossimEllipsoid(){};
56 
60  const ossimString& name()const{return theName;}
61  const ossimString& code()const{return theCode;}
62 
63  const double& a()const{return theA;} // major axis
64  const double& b()const{return theB;} // minor axis
65 
66  const double& getA()const{return theA;}
67  const double& getB()const{return theB;}
68  const double& getFlattening()const{return theFlattening;}
69 
70  void setA(double a){theA = a;computeFlattening();}
71  void setB(double b){theB = b;computeFlattening();}
72  void setAB(double a, double b){theA = a; theB = b; computeFlattening();}
73  void setEpsgCode(ossim_uint32 code) {theEpsgCode = code;}
74  double eccentricitySquared() const { return theEccentricitySquared; }
75 
76  double flattening()const { return theFlattening; }
77 
78  double eccentricity()const { return std::sqrt(theEccentricitySquared); }
79 
80  ossim_uint32 getEpsgCode() const;
81 
90  bool nearestIntersection(const ossimEcefRay& ray,
91  ossimEcefPoint& rtnPt) const;
92  bool nearestIntersection(const ossimEcefRay& ray,
93  const double& offset,
94  ossimEcefPoint& rtnPt) const;
95 
100  double evaluate(const ossimEcefPoint&)const;
101 
107  void gradient(const ossimEcefPoint& location,
108  ossimEcefVector& result)const;
109  ossimEcefVector gradient(const ossimEcefPoint& loc)const;
110 
115  void prinRadiiOfCurv(const ossimEcefPoint& location,
116  double& merRadius,
117  double& primeVert)const;
118 
123  void jacobianWrtEcef(const ossimEcefPoint& location,
124  NEWMAT::Matrix& jMat)const;
125 
130  void jacobianWrtGeo(const ossimEcefPoint& location,
131  NEWMAT::Matrix& jMat)const;
132 
136  double geodeticRadius(const double& latitude) const;
137 
142  void geodeticRadii(const double& latitude, ossimDpt& radii) const;
143 
144  void latLonHeightToXYZ(double lat, double lon, double height,
145  double &x, double &y, double &z)const;
146  void XYZToLatLonHeight(double x, double y, double z,
147  double& lat, double& lon, double& height)const;
148 
149  //---
150  // this is a utility from open scene graph that allows you to create a
151  // local space rotational
152  // and translation matrix
153  //---
154  void computeLocalToWorldTransformFromXYZ(double x, double y, double z,
155  ossimMatrix4x4& localToWorld)const;
156 
157  bool operator ==(const ossimEllipsoid& rhs)const
158  {
159  return ( (theName == rhs.theName)&&
160  (theCode == rhs.theCode)&&
161  (theA == rhs.theA)&&
162  (theB == rhs.theB)&&
163  (theFlattening == rhs.theFlattening));
164  }
165 
166  bool operator!=(const ossimEllipsoid& rhs) const
167  {
168  return ( (theName != rhs.theName)||
169  (theCode != rhs.theCode)||
170  (theA != rhs.theA)||
171  (theB != rhs.theB)||
172  (theFlattening != rhs.theFlattening));
173  }
174 
175  bool loadState(const ossimKeywordlist& kwl,
176  const char* prefix=0);
177  bool saveState(ossimKeywordlist& kwl,
178  const char* prefix=0)const;
179 
180  const ossimEllipsoid& operator=(const ossimEllipsoid& copy_me);
181 
182  virtual bool isEqualTo(const ossimEllipsoid& rhs,
183  ossimCompareType compareType=OSSIM_COMPARE_FULL)const;
184 
185 protected:
187  {
188  theFlattening = (theA - theB)/theA;
189  }
190 
194  double theA; //semi-major axis in meters
195  double theB; //semi-minor axis in meters
197  double theA_squared;
198  double theB_squared;
200 
201 }; // class OSSIMDLLEXPORT ossimEllipsoid
202 
204  ossimCompareType /* compareType */)const
205 {
206  return ((theName == rhs.theName)&&
207  (theCode == rhs.theCode)&&
208  (theEpsgCode ==rhs.theEpsgCode)&&
213 }
214 
215 #endif /* #ifndef ossimEllipsoid_HEADER */
ossim_uint32 x
double eccentricity() const
double theEccentricitySquared
virtual ~ossimEllipsoid()
#define OSSIMDLLEXPORT
Represents serializable keyword/value map.
ossim_uint32 y
void setB(double b)
bool almostEqual(T x, T y, T tolerance=FLT_EPSILON)
Definition: ossimCommon.h:53
double flattening() const
ossimCompareType
const double & b() const
void setAB(double a, double b)
virtual bool isEqualTo(const ossimEllipsoid &rhs, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
ossimString theCode
const double & a() const
const ossimString & name() const
const double & getA() const
unsigned int ossim_uint32
double eccentricitySquared() const
bool operator==(const ossimRefPtr< _Tp1 > &__a, const ossimRefPtr< _Tp2 > &__b) noexcept
Definition: ossimRefPtr.h:101
void setEpsgCode(ossim_uint32 code)
const ossimString & code() const
ossim_uint32 theEpsgCode
const double & getB() const
void setA(double a)
const double & getFlattening() const
void computeFlattening()
ossimString theName
bool operator!=(const ossimEllipsoid &rhs) const