Isis 3 Programmer Reference
Intercept.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include "Intercept.h"
9 
10 #include <numeric>
11 #include <string>
12 #include <vector>
13 
14 #include <QtGlobal>
15 
16 #include "Angle.h"
17 #include "AbstractPlate.h"
18 #include "IException.h"
19 #include "IString.h"
20 #include "NaifDskApi.h"
21 #include "Latitude.h"
22 #include "Longitude.h"
23 #include "SurfacePoint.h"
24 
25 using namespace std;
26 
27 namespace Isis {
28 
30  Intercept::Intercept() : m_observer(), m_raydir(), m_point(0), m_shape(0) { }
31 
32 
33 
50  Intercept::Intercept(const NaifVertex &observer, const NaifVector &raydir,
51  SurfacePoint *ipoint, AbstractPlate *shape) :
52  m_observer(observer.copy()), m_raydir(raydir.copy()),
53  m_point(ipoint), m_shape(shape) {}
54 
55 
56 
57 
60 
61 
62 
70  bool Intercept::isValid() const {
71  bool valid = true;
72  if ( !validate( m_observer ) ) valid = false;
73  if ( !validate( m_raydir ) ) valid = false;
74  if ( m_point.isNull() ) valid = false;
75  if ( m_shape.isNull() ) valid = false;
76  return valid;
77  }
78 
79 
80 
88  return (m_observer);
89  }
90 
91 
92 
100  return (m_raydir);
101  }
102 
103 
104 
117  verify( isValid(), "Unable to return Intercept location. Invalid/undefined Intercept point.");
118  return (SurfacePoint(*m_point));
119  }
120 
121 
122 
130  verify( isValid(), "Unable to return Intercept normal. Invalid/undefined Intercept point.");
131  return ( m_shape->normal() );
132  }
133 
134 
135 
136 
151  verify( isValid(),
152  "Unable to return Intercept emission angle. Invalid/undefined Intercept point." );
153 
154  // Point back toward the center of the body
155  NaifVertex point(3);
156  m_point->ToNaifArray(&point[0]);
157 
158  NaifVector raydir(3);
159  vsub_c(&m_observer[0], &point[0], &raydir[0]);
160 
161  // Return the separation angle between them
162  return (separationAngle(raydir));
163  }
164 
165 
166 
183  verify( isValid(),
184  "Unable to return Intercept separation angle. Invalid/undefined Intercept point.");
185  return (m_shape->separationAngle(raydir));
186  }
187 
188 
189 
205  bool Intercept::verify(const bool &test, const QString &errmsg,
206  const Intercept::ErrAction &action) const {
207  if ( ( Throw == action ) && ( !test ) ) {
208  throw IException(IException::Programmer, errmsg, _FILEINFO_);
209  }
210 
211  // Looks good
212  return ( test );
213  }
214 
215 
216 
224  return ( m_shape.data() );
225  }
226 
227 }
228 // namespace Isis
Isis::Intercept::separationAngle
Angle separationAngle(const NaifVector &raydir) const
Returns the separation angle of the observer and the plate normal.
Definition: Intercept.cpp:182
Isis::NaifVertex
TNT::Array1D< SpiceDouble > NaifVertex
1-D Buffer[3]
Definition: NaifDskApi.h:47
Isis::Intercept::location
SurfacePoint location() const
Returns the location of the intercept location on the shape.
Definition: Intercept.cpp:116
Isis::Intercept::Throw
@ Throw
Throw an exception if an error occurs.
Definition: Intercept.h:62
Isis::Intercept::normal
NaifVector normal() const
Gets the normal vector to the shape for this plate.
Definition: Intercept.cpp:129
Isis::Intercept::emission
Angle emission() const
Compute the emission of the intercept point from the observer.
Definition: Intercept.cpp:150
Isis::Intercept::m_observer
NaifVertex m_observer
Three dimensional coordinate position of the observer, in body fixed.
Definition: Intercept.h:69
Isis::AbstractPlate
Abstract interface to a TIN plate.
Definition: AbstractPlate.h:46
Isis::Intercept::~Intercept
virtual ~Intercept()
Empty destructor.
Definition: Intercept.cpp:59
Isis::Intercept::lookDirectionRay
const NaifVector & lookDirectionRay() const
Accessor for the look direction of the intercept.
Definition: Intercept.cpp:99
Isis::Intercept::m_point
QSharedPointer< SurfacePoint > m_point
Surface point of the intercept location on the body, in body fixed.
Definition: Intercept.h:72
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Angle
Defines an angle and provides unit conversions.
Definition: Angle.h:45
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
std
Namespace for the standard library.
Isis::Intercept::ErrAction
ErrAction
Enumeration to indicate whether to throw an exception if an error occurs.
Definition: Intercept.h:62
Isis::Intercept::observer
const NaifVertex & observer() const
Accessor for the observer position of the intercept.
Definition: Intercept.cpp:87
Isis::Intercept::verify
bool verify(const bool &test, const QString &errmsg, const ErrAction &action=Throw) const
Convenient error handler.
Definition: Intercept.cpp:205
Isis::Intercept::isValid
bool isValid() const
This method tests the vailidty of the intercept point.
Definition: Intercept.cpp:70
Isis::NaifVector
TNT::Array1D< SpiceDouble > NaifVector
Namespace to contain type definitions of NAIF DSK fundamentals.
Definition: NaifDskApi.h:46
Isis::validate
bool validate(const NaifVertex &v)
Verifies that the given NaifVector or NaifVertex is 3 dimensional.
Definition: NaifDskApi.cpp:28
Isis::Intercept::m_raydir
NaifVector m_raydir
Three dimensional ray representing the look direction.
Definition: Intercept.h:70
Isis::Intercept::Intercept
Intercept()
Default empty constructor.
Definition: Intercept.cpp:30
Isis::SurfacePoint
This class defines a body-fixed surface point.
Definition: SurfacePoint.h:132
Isis::Intercept::shape
const AbstractPlate * shape() const
Access the plate for this intercept.
Definition: Intercept.cpp:223
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::Intercept::m_shape
QSharedPointer< AbstractPlate > m_shape
Shape Model for the intercept point.
Definition: Intercept.h:74