OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimEcefRay.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // DESCRIPTION:
6 // Class for representing a ray in the earth-centered, earth-fixed (ECEF)
7 // coordinate system. A ray is defined as having an origin point and a
8 // unit direction vector radiating from the origin.
9 //
10 // SOFTWARE HISTORY:
11 //>
12 // 10Aug2001 Oscar Kramer (okramer@imagelinks.com)
13 // Initial coding.
14 //<
15 //*****************************************************************************
16 // $Log$
17 // Revision 1.4 2006/11/29 02:01:07 gpotts
18 // pdated license
19 //
20 // Revision 1.3 2006/06/13 19:10:51 dburken
21 // Global include path change.
22 //
23 // Revision 1.2 2002/05/31 12:51:14 okramer
24 // Added ossimEcefRay::intersectAboveEarthEllipsoid()
25 //
26 // Revision 1.1 2001/08/14 15:01:45 okramer
27 // Initial delivery (okramer@imagelinks.com)
28 //
29 
30 #include <ostream>
31 
33 #include <ossim/base/ossimGpt.h>
34 #include <ossim/base/ossimDatum.h>
36 
37 //***
38 // Define Trace flags for use within this file:
39 //***
40 #include <ossim/base/ossimTrace.h>
41 static ossimTrace traceExec ("ossimEcefRay:exec");
42 static ossimTrace traceDebug ("ossimEcefRay:debug");
43 
44 //*****************************************************************************
45 // CONSTRUCTOR: ossimEcefRay(ossimEcefPoint, ossimEcefPoint)
46 //
47 // Constructs a ray originating at "from" and pointing in direction of "to"
48 //
49 //*****************************************************************************
51  const ossimEcefPoint& to)
52  : theOrigin(from)
53 {
54  ossimEcefVector ecef (to - from);
55  ecef.normalize();
56  theDirection = ecef;
57 }
58 
59 
60 //*****************************************************************************
61 // CONSTRUCTOR: ossimEcefRay(ossimGpt, ossimGpt)
62 //
63 // Constructs a ray originating at "from" and pointing in direction of "to"
64 //
65 //*****************************************************************************
67  const ossimGpt& to)
68  : theOrigin(from)
69 {
71  ecef.normalize();
72  theDirection = ecef;
73 }
74 
75 //*****************************************************************************
76 // METHOD: ossimEcefRay::intersectAboveEarthEllipsoid
77 //
78 // Intersects the ray with the given elevation above the earth ellipsoid.
79 //
80 //*****************************************************************************
82  (const double& argHeight,
83  const ossimDatum* argDatum) const
84 {
85  const ossimDatum* datum = argDatum;
86  if (!datum)
88 
89  //***
90  // Pass the call on to ellipsoid where intersection math is implemented:
91  //***
92  ossimEcefPoint solution;
93  bool intersected = datum->ellipsoid()->nearestIntersection
94  (*this, argHeight, solution);
95 
96  if (!intersected)
97  solution.makeNan();
98 
99  return solution;
100 }
101 
103 {
104  os << "(ossimEcefRay)\n"
105  << " theOrigin = " << theOrigin
106  << "\n theDirection = " << theDirection << std::endl;
107  return os;
108 }
109 
111  const ossimEcefRay& instance)
112 {
113  return instance.print(os);
114 }
115 
116 
std::ostream & operator<<(std::ostream &os, const ossimEcefRay &instance)
std::ostream & print(std::ostream &os=ossimNotify(ossimNotifyLevel_INFO)) const
ossimEcefPoint intersectAboveEarthEllipsoid(const double &heightAboveEllipsoid, const ossimDatum *aDatum=ossimDatumFactory::instance() ->wgs84()) const
virtual const ossimEllipsoid * ellipsoid() const
Definition: ossimDatum.h:60
static ossimDatumFactory * instance()
ossimEcefVector theDirection
Definition: ossimEcefRay.h:115
ossimEcefPoint theOrigin
Definition: ossimEcefRay.h:114
const ossimDatum * wgs84() const
bool nearestIntersection(const ossimEcefRay &ray, ossimEcefPoint &rtnPt) const
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23