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
25using namespace std;
26
27namespace 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
Abstract interface to a TIN plate.
Defines an angle and provides unit conversions.
Definition Angle.h:45
Isis exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
bool verify(const bool &test, const QString &errmsg, const ErrAction &action=Throw) const
Convenient error handler.
bool isValid() const
This method tests the vailidty of the intercept point.
Definition Intercept.cpp:70
NaifVector normal() const
Gets the normal vector to the shape for this plate.
QSharedPointer< AbstractPlate > m_shape
Shape Model for the intercept point.
Definition Intercept.h:74
NaifVertex m_observer
Three dimensional coordinate position of the observer, in body fixed.
Definition Intercept.h:69
SurfacePoint location() const
Returns the location of the intercept location on the shape.
NaifVector m_raydir
Three dimensional ray representing the look direction.
Definition Intercept.h:70
Angle separationAngle(const NaifVector &raydir) const
Returns the separation angle of the observer and the plate normal.
QSharedPointer< SurfacePoint > m_point
Surface point of the intercept location on the body, in body fixed.
Definition Intercept.h:72
virtual ~Intercept()
Empty destructor.
Definition Intercept.cpp:59
const AbstractPlate * shape() const
Access the plate for this intercept.
const NaifVertex & observer() const
Accessor for the observer position of the intercept.
Definition Intercept.cpp:87
const NaifVector & lookDirectionRay() const
Accessor for the look direction of the intercept.
Definition Intercept.cpp:99
ErrAction
Enumeration to indicate whether to throw an exception if an error occurs.
Definition Intercept.h:62
@ Throw
Throw an exception if an error occurs.
Definition Intercept.h:62
Angle emission() const
Compute the emission of the intercept point from the observer.
Intercept()
Default empty constructor.
Definition Intercept.cpp:30
This class defines a body-fixed surface point.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
TNT::Array1D< SpiceDouble > NaifVector
Namespace to contain type definitions of NAIF DSK fundamentals.
Definition NaifDskApi.h:46
TNT::Array1D< SpiceDouble > NaifVertex
1-D Buffer[3]
Definition NaifDskApi.h:47
bool validate(const NaifVertex &v)
Verifies that the given NaifVector or NaifVertex is 3 dimensional.
Namespace for the standard library.