OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimEcefPoint.h
Go to the documentation of this file.
1 //*****************************************************************************
2 // FILE: ossimEcefPoint.h
3 //
4 // License: See top level LICENSE.txt file.
5 //
6 // DESCRIPTION:
7 // Contains declaration of a 3D point object in the Earth-centered, earth
8 // fixed (ECEF) coordinate system.
9 //
10 // SOFTWARE HISTORY:
11 //>
12 // 08Aug2001 Oscar Kramer (http://www.oscarkramer.com)
13 // Initial coding.
14 //<
15 //*****************************************************************************
16 // $Id: ossimEcefPoint.h 20043 2011-09-06 15:00:55Z oscarkramer $
17 
18 #ifndef ossimEcefPoint_HEADER
19 #define ossimEcefPoint_HEADER
20 #include <iosfwd>
21 #include <ossim/base/ossimCommon.h>
23 #include <ossim/base/ossimNotify.h>
24 #include <ossim/base/ossimString.h>
25 #include <ossim/matrix/newmat.h>
26 
27 class ossimGpt;
28 class ossimEcefVector;
29 class ossimDpt3d;
30 
31 //*****************************************************************************
32 // CLASS: ossimEcefPoint
33 //
34 //*****************************************************************************
36 {
37 public:
42  : theData(0,0,0) {}
43 
44  // Default definition is perfect
45  // ossimEcefPoint(const ossimEcefPoint& copy_this) = default;
46 
47  ossimEcefPoint(const ossimGpt& convert_this);
48 
49  ossimEcefPoint(const double& x,
50  const double& y,
51  const double& z)
52  : theData(x, y, z) {}
53 
54  ossimEcefPoint(const ossimColumnVector3d& assign_this)
55  : theData(assign_this) {}
56 
57  ossimEcefPoint(const NEWMAT::ColumnVector& assign_this)
58  : theData(assign_this) {}
59 
60  ossimEcefPoint(const ossimDpt3d& pt);
61 
62  void makeNan()
63  {
64  theData[0] = ossim::nan();
65  theData[1] = ossim::nan();
66  theData[2] = ossim::nan();
67  }
68 
69  bool hasNans()const
70  {
71  return ( ossim::isnan(theData[0]) ||
72  ossim::isnan(theData[1]) ||
73  ossim::isnan(theData[2]) );
74 
75  }
76 
77  bool isNan()const
78  {
79  return ( ossim::isnan(theData[0]) &&
80  ossim::isnan(theData[1]) &&
81  ossim::isnan(theData[2]) );
82 
83  }
90  // ossimEcefPoint& operator= (const ossimEcefPoint&) = default;
91  bool operator==(const ossimEcefPoint&) const; // inline
92  bool operator!=(const ossimEcefPoint&) const; // inline
93 
97  double x() const { return theData[0]; }
98  double& x() { return theData[0]; }
99  double y() const { return theData[1]; }
100  double& y() { return theData[1]; }
101  double z() const { return theData[2]; }
102  double& z() { return theData[2]; }
103  double& operator[](int idx){return theData[idx];}
104  const double& operator[](int idx)const{return theData[idx];}
105  const ossimColumnVector3d& data() const { return theData; }
106  ossimColumnVector3d& data() { return theData; }
107 
108  double getMagnitude() const
109  {
110  return theData.magnitude();
111  }
112  double magnitude()const
113  {
114  return theData.magnitude();
115  }
116  double length()const
117  {
118  return theData.magnitude();
119  }
120  double normalize()
121  {
122  double result = magnitude();
123 
124  if(result > 1e-15)
125  {
126  theData[0]/=result;
127  theData[1]/=result;
128  theData[2]/=result;
129  }
130 
131  return result;
132  }
133 
145  ossimString toString(ossim_uint32 precision=15) const;
146 
157  void toPoint(const std::string& s);
158 
160  NEWMAT::ColumnVector toVector() const
161  {
162  NEWMAT::ColumnVector v (3);
163  v(0) = theData[0];
164  v(1) = theData[1];
165  v(2) = theData[2];
166  return v;
167  }
168 
170  void toPoint(const NEWMAT::ColumnVector& v)
171  {
172  if (v.Nrows() == 3)
173  {
174  theData[0] = v[0];
175  theData[1] = v[1];
176  theData[2] = v[2];
177  }
178  }
179 
184 
186  const ossimEcefPoint& instance);
187 
188 protected:
190 };
191 
192 //================== BEGIN DEFINITIONS FOR INLINE METHODS =====================
193 
194 //*****************************************************************************
195 // INLINE METHOD: ossimEcefPoint::operator==(ossimEcefPoint)
196 //*****************************************************************************
197 inline bool ossimEcefPoint::operator==(const ossimEcefPoint& p) const
198 {
199  return (theData == p.theData);
200 }
201 
202 //*****************************************************************************
203 // INLINE METHOD: ossimEcefPoint::operator!=(ossimEcefPoint)
204 //*****************************************************************************
205 inline bool ossimEcefPoint::operator!=(const ossimEcefPoint& p) const
206 {
207  return (theData != p.theData);
208 }
209 
210 #endif
const ossimColumnVector3d & data() const
ossim_uint32 x
void toPoint(const NEWMAT::ColumnVector &v)
Converts 3D column vector to this point.
bool operator!=(const ossimEcefPoint &) const
double & x()
ossimRationalNumber operator-(ossim_int32 i, ossimRationalNumber &r)
ossimEcefPoint(const ossimColumnVector3d &assign_this)
#define OSSIMDLLEXPORT
bool hasNans() const
bool operator!=(const ossimRefPtr< _Tp1 > &__a, const ossimRefPtr< _Tp2 > &__b) noexcept
Definition: ossimRefPtr.h:111
ossimEcefPoint(const double &x, const double &y, const double &z)
ossim_uint32 y
double getMagnitude() const
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double x() const
const double & operator[](int idx) const
std::ostream & print(H5::H5File *file, std::ostream &out)
Print method.
Definition: ossimH5Util.cpp:41
double magnitude() const
ostream & operator<<(ostream &out, const ossimAxes &axes)
Definition: ossimAxes.h:88
unsigned int ossim_uint32
bool operator==(const ossimEcefPoint &) const
bool operator==(const ossimRefPtr< _Tp1 > &__a, const ossimRefPtr< _Tp2 > &__b) noexcept
Definition: ossimRefPtr.h:101
ossimColumnVector3d & data()
double y() const
ossimEcefPoint(const NEWMAT::ColumnVector &assign_this)
#define OSSIM_DLL
double length() const
bool isNan() const
double normalize()
NEWMAT::ColumnVector toVector() const
Converts this point to a 3D column vector.
double & operator[](int idx)
ossimRationalNumber operator+(ossim_int32 i, ossimRationalNumber &r)
double z() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
ossimColumnVector3d theData
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91