OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimLsrVector.h
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // DESCRIPTION:
6 // Class for representing vectors in some local space rectangular (LSR)
7 // coordinate system. This coordinate system is related to the ECEF system
8 // by the ossimLsrSpace member object. This class simplifies coordinate
9 // conversions between LSR and ECEF, and other LSR vectors.
10 //
11 // SOFTWARE HISTORY:
12 //>
13 // 08Aug2001 Oscar Kramer
14 // Initial coding.
15 //<
16 //*****************************************************************************
17 // $Id: ossimLsrVector.h 12790 2008-05-05 13:41:33Z dburken $
18 
19 #ifndef ossimLsrVector_HEADER
20 #define ossimLsrVector_HEADER
21 
22 #include <iosfwd>
23 
24 #include <ossim/base/ossimCommon.h>
29 
30 class ossimGpt;
31 
32 //*****************************************************************************
33 // CLASS: ossimLsrVector
34 //
35 //*****************************************************************************
37 {
38 public:
43  : theData (0,0,0) {}
44 
45  ossimLsrVector(const ossimLsrVector& copy_this)
46  : theData(copy_this.theData), theLsrSpace(copy_this.theLsrSpace) {}
47 
48  ossimLsrVector(const ossimColumnVector3d& assign_this,
49  const ossimLsrSpace& space)
50  : theData(assign_this), theLsrSpace(space) {}
51 
52  ossimLsrVector(const double& x,
53  const double& y,
54  const double& z,
55  const ossimLsrSpace& space)
56  : theData(x,y,z), theLsrSpace(space) {}
57 
58  ossimLsrVector(const ossimEcefVector& convert_this,
59  const ossimLsrSpace&);
60  ossimLsrVector(const ossimLsrVector& convert_this,
61  const ossimLsrSpace&);
62 
66  const ossimLsrVector& operator= (const ossimLsrVector&);
67  ossimLsrVector operator- () const;
71  ossimLsrVector operator* (const double& scalar) const;
72  ossimLsrVector operator/ (const double& scalar) const;
73  bool operator==(const ossimLsrVector&) const;
74  bool operator!=(const ossimLsrVector&) const;
75 
82  operator ossimEcefVector() const; // inline below
83 
87  double dot(const ossimLsrVector&) const;
88  double angleTo(const ossimLsrVector&) const;
89  ossimLsrVector cross(const ossimLsrVector&) const;
90  ossimLsrVector unitVector() const;//inline below
91  double magnitude() const;//inline below
92  void normalize(); // inline below
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 
104  bool hasNans()const
105  {
106  return (ossim::isnan(theData[0])||
107  ossim::isnan(theData[1])||
108  ossim::isnan(theData[2]));
109  }
110  void makeNan()
111  {
112  theData[0] = ossim::nan();
113  theData[1] = ossim::nan();
114  theData[2] = ossim::nan();
115  }
116  ossimColumnVector3d& data() { return theData; }
117  const ossimColumnVector3d& data() const { return theData; }
118 
119  ossimLsrSpace& lsrSpace() { return theLsrSpace; }
120  const ossimLsrSpace& lsrSpace() const { return theLsrSpace; }
121 
125  std::ostream& print(ostream& stream) const;
126 
128  const ossimLsrVector& instance);
129 
130 protected:
136  void initialize(const ossimEcefVector& ecef_point);
137 
140 
141 };
142 
143 //================== BEGIN DEFINITIONS FOR INLINE METHODS =====================
144 
145 //*****************************************************************************
146 // INLINE OPERATOR: ossimLsrVector::operator=(ossimLsrVector)
147 //*****************************************************************************
149 {
150  theData = v.theData;
152 
153  return *this;
154 }
155 
156 //*****************************************************************************
157 // INLINE OPERATOR: ossimLsrVector::operator-() (negate)
158 //*****************************************************************************
160 {
162 }
163 
164 //*****************************************************************************
165 // INLINE OPERATOR: ossimLsrVector::operator+(ossimLsrVector)
166 //*****************************************************************************
168 {
169  if ((theLsrSpace != v.theLsrSpace)||hasNans()||v.hasNans())
170  {
173  }
175 
176 }
177 
178 //*****************************************************************************
179 // INLINE OPERATOR: ossimLsrVector::operator-(ossimLsrVector)
180 //*****************************************************************************
182 {
183  if ((theLsrSpace != v.theLsrSpace)||hasNans()||v.hasNans())
184  {
187  }
188  return ossimLsrVector(theData - v.data(), theLsrSpace);
189 }
190 
191 //*****************************************************************************
192 // INLINE OPERATOR: ossimLsrVector::operator+(ossimLsrPoint)
193 //*****************************************************************************
195 {
196  if ((theLsrSpace != p.lsrSpace())||hasNans()||p.hasNans())
197  {
200  }
201  return ossimLsrPoint(theData + p.data(), theLsrSpace);
202 }
203 
204 //*****************************************************************************
205 // INLINE OPERATOR: ossimLsrVector::operator*(double scalar)
206 //*****************************************************************************
207 inline ossimLsrVector ossimLsrVector::operator*(const double& scalar) const
208 {
209  return ossimLsrVector(theData*scalar, theLsrSpace);
210 }
211 
212 //*****************************************************************************
213 // INLINE OPERATOR: ossimLsrVector::operator/(double scalar)
214 //*****************************************************************************
215 inline ossimLsrVector ossimLsrVector::operator/(const double& scalar) const
216 {
217  return ossimLsrVector(theData/scalar, theLsrSpace);
218 }
219 
220 //*****************************************************************************
221 // INLINE OPERATOR: ossimLsrVector::operator==(ossimLsrVector)
222 //*****************************************************************************
223 inline bool ossimLsrVector::operator==(const ossimLsrVector& v) const
224 {
225  return ((theData == v.theData) && (theLsrSpace == v.theLsrSpace));
226 }
227 
228 //*****************************************************************************
229 // INLINE OPERATOR: ossimLsrVector::operator!=(ossimLsrVector)
230 //*****************************************************************************
231 inline bool ossimLsrVector::operator!=(const ossimLsrVector& v) const
232 {
233  return (!(*this == v));
234 }
235 
236 //*****************************************************************************
237 // INLINE OPERATOR: ossimEcefVector()
238 //
239 // Looks like a constructor for an ossimEcefVector but is an operation on this
240 // object. Returns the ossimEcefVector equivalent.
241 //
242 //*****************************************************************************
243 inline ossimLsrVector::operator ossimEcefVector() const
244 {
245  return ossimEcefVector(theLsrSpace.lsrToEcefRotMatrix()*theData);
246 }
247 
248 //*****************************************************************************
249 // INLINE METHOD: ossimLsrVector::unitVector()
250 // Returns a unit vector parallel to this.
251 //*****************************************************************************
253 {
255 
257 }
258 
259 //*****************************************************************************
260 // INLINE METHOD: ossimLsrVector::magnitude()
261 //*****************************************************************************
262 inline double ossimLsrVector::magnitude() const
263 {
264  if(hasNans()) return ossim::nan();
265  return theData.magnitude();
266 }
267 
268 //*****************************************************************************
269 // INLINE METHOD: ossimLsrVector::normalize()
270 // Normalizes this vector.
271 //*****************************************************************************
273 {
275 }
276 
277 //*****************************************************************************
278 // PROTECTED INLINE METHOD: ossimLsrPoint::initialize(ossimEcefPoint)
279 //
280 // Convenience method used by several constructors for initializing theData
281 // given an ECEF point. Assumes theLsrSpace has been previously initialized.
282 //
283 //*****************************************************************************
284 inline void ossimLsrVector::initialize(const ossimEcefVector& ecef_vector)
285 {
286  theData = theLsrSpace.ecefToLsrRotMatrix() * ecef_vector.data();
287 }
288 
289 #endif
290 
291 
ossim_uint32 x
void initialize(const ossimEcefVector &ecef_point)
static ostream & lsrSpaceErrorMessage(ostream &os=ossimNotify(ossimNotifyLevel_INFO))
ossimRationalNumber operator-(ossim_int32 i, ossimRationalNumber &r)
#define OSSIMDLLEXPORT
const ossimColumnVector3d & data() const
ossimLsrVector operator+(const ossimLsrVector &) const
bool operator!=(const ossimRefPtr< _Tp1 > &__a, const ossimRefPtr< _Tp2 > &__b) noexcept
Definition: ossimRefPtr.h:111
ossim_uint32 y
double z() const
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
ossimRationalNumber operator/(ossim_int32 i, ossimRationalNumber &r)
ossimLsrSpace & lsrSpace()
ossimColumnVector3d & data()
bool operator==(const ossimLsrVector &) const
std::ostream & print(H5::H5File *file, std::ostream &out)
Print method.
Definition: ossimH5Util.cpp:41
bool hasNans() const
ossimLsrVector(const ossimLsrVector &copy_this)
double x() const
ossimRationalNumber operator*(ossim_int32 i, ossimRationalNumber &r)
const ossimLsrSpace & lsrSpace() const
ostream & operator<<(ostream &out, const ossimAxes &axes)
Definition: ossimAxes.h:88
ossimColumnVector3d & data()
Definition: ossimLsrPoint.h:92
ossimLsrVector unitVector() const
bool operator!=(const ossimLsrVector &) const
ossimLsrVector operator/(const double &scalar) const
ossimLsrSpace theLsrSpace
bool operator==(const ossimRefPtr< _Tp1 > &__a, const ossimRefPtr< _Tp2 > &__b) noexcept
Definition: ossimRefPtr.h:101
bool hasNans() const
Definition: ossimLsrPoint.h:98
ossimLsrVector(const ossimColumnVector3d &assign_this, const ossimLsrSpace &space)
NEWMAT::Matrix ecefToLsrRotMatrix() const
ossimColumnVector3d theData
ossimLsrSpace & lsrSpace()
Definition: ossimLsrPoint.h:95
double & x()
const ossimColumnVector3d & data() const
ossimLsrVector operator-() const
double magnitude() const
ossimRationalNumber operator+(ossim_int32 i, ossimRationalNumber &r)
const ossimLsrVector & operator=(const ossimLsrVector &)
ossimLsrVector operator*(const double &scalar) const
ossimLsrVector(const double &x, const double &y, const double &z, const ossimLsrSpace &space)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
double y() const
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91