Isis 3 Programmer Reference
EllipsoidShape.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "EllipsoidShape.h"
8 
9 #include <QVector>
10 
11 
12 #include <SpiceUsr.h>
13 #include <SpiceZfc.h>
14 #include <SpiceZmc.h>
15 
16 #include "Distance.h"
17 #include "IException.h"
18 #include "IString.h"
19 #include "Latitude.h"
20 #include "Longitude.h"
21 #include "NaifStatus.h"
22 #include "ShapeModel.h"
23 #include "SurfacePoint.h"
24 
25 using namespace std;
26 
27 namespace Isis {
28 
34  EllipsoidShape::EllipsoidShape(Target *target) : ShapeModel (target) {
35  setName("Ellipsoid");
36  }
37 
38 
45  setName("Ellipsoid");
46  }
47 
48 
52  bool EllipsoidShape::intersectSurface (std::vector<double> observerPos,
53  std::vector<double> lookDirection) {
54 
55  return (intersectEllipsoid(observerPos, lookDirection));
56  }
57 
58 
63  QVector <double *> points;
64  calculateLocalNormal(points);
65  }
66 
67 
72  QVector <double *> points;
73  calculateLocalNormal(points);
74  }
75 
76 
84  bool EllipsoidShape::isDEM() const {
85  return false;
86  }
87 
88 
109 
110  if (!surfaceIntersection()->Valid() || !hasIntersection()) {
111  IString msg = "A valid intersection must be defined before computing the surface normal";
112  throw IException(IException::Programmer, msg, _FILEINFO_);
113  }
114 
115  // Get the coordinates of the current surface point
116  SpiceDouble pB[3];
117  pB[0] = surfaceIntersection()->GetX().kilometers();
118  pB[1] = surfaceIntersection()->GetY().kilometers();
119  pB[2] = surfaceIntersection()->GetZ().kilometers();
120 
121  // Get the radii of the ellipsoid
122  vector<Distance> radii = targetRadii();
123  double a = radii[0].kilometers();
124  double b = radii[1].kilometers();
125  double c = radii[2].kilometers();
126 
127  vector<double> normal(3,0.);
129  surfnm_c(a, b, c, pB, (SpiceDouble *) &normal[0]);
131 
132  setNormal(normal);
133  setHasNormal(true);
134  }
135 
136 
145 
146  std::vector<Distance> radii = targetRadii();
147 
148  double a = radii[0].kilometers();
149  double b = radii[1].kilometers();
150  double c = radii[2].kilometers();
151 
152  double rlat = lat.radians();
153  double rlon = lon.radians();
154 
155  double xyradius = a * b / sqrt(pow(b * cos(rlon), 2) +
156  pow(a * sin(rlon), 2));
157  const double &radius = xyradius * c / sqrt(pow(c * cos(rlat), 2) +
158  pow(xyradius * sin(rlat), 2));
159 
160  return Distance(radius, Distance::Kilometers);
161  }
162 
163 }
Isis::EllipsoidShape::localRadius
Distance localRadius(const Latitude &lat, const Longitude &lon)
Get the local radius for a point on the surface.
Definition: EllipsoidShape.cpp:144
Isis::Latitude
This class is designed to encapsulate the concept of a Latitude.
Definition: Latitude.h:51
Isis::ShapeModel::surfaceIntersection
SurfacePoint * surfaceIntersection() const
Returns the surface intersection for this ShapeModel.
Definition: ShapeModel.cpp:358
Isis::ShapeModel::targetRadii
std::vector< Distance > targetRadii() const
Returns the radii of the body in km.
Definition: ShapeModel.cpp:465
Isis::EllipsoidShape::calculateDefaultNormal
virtual void calculateDefaultNormal()
Calculate the default normal of the current intersection point.
Definition: EllipsoidShape.cpp:62
Isis::EllipsoidShape::intersectSurface
bool intersectSurface(std::vector< double > observerPos, std::vector< double > lookDirection)
Intersect the shape model.
Definition: EllipsoidShape.cpp:52
Isis::EllipsoidShape::calculateSurfaceNormal
void calculateSurfaceNormal()
Calculate the surface normal of the current intersection point.
Definition: EllipsoidShape.cpp:71
Isis::NaifStatus::CheckErrors
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:28
Isis::ShapeModel::setNormal
void setNormal(const std::vector< double >)
Sets the normal for the currect intersection point.
Definition: ShapeModel.cpp:487
Isis::Distance
Distance measurement, usually in meters.
Definition: Distance.h:34
Isis::Longitude
This class is designed to encapsulate the concept of a Longitude.
Definition: Longitude.h:40
Isis::Distance::Kilometers
@ Kilometers
The distance is being specified in kilometers.
Definition: Distance.h:45
Isis::ShapeModel::setName
void setName(QString name)
Sets the shape name.
Definition: ShapeModel.cpp:532
Isis::EllipsoidShape::EllipsoidShape
EllipsoidShape()
Initialize the EllipsoidShape.
Definition: EllipsoidShape.cpp:44
Isis::ShapeModel::intersectEllipsoid
bool intersectEllipsoid(const std::vector< double > observerPosRelativeToTarget, const std::vector< double > &observerLookVectorToTarget)
Finds the intersection point on the ellipsoid model using the given position of the observer (spacecr...
Definition: ShapeModel.cpp:267
Isis::EllipsoidShape::calculateLocalNormal
void calculateLocalNormal(QVector< double * > cornerNeighborPoints)
Calculate the local surface normal of the current intersection point.
Definition: EllipsoidShape.cpp:108
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::ShapeModel::setHasNormal
void setHasNormal(bool status)
Sets the flag to indicate whether this ShapeModel has a surface normal.
Definition: ShapeModel.cpp:581
Isis::Displacement::kilometers
double kilometers() const
Get the displacement in kilometers.
Definition: Displacement.cpp:94
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::ShapeModel
Define shapes and provide utilities for Isis targets.
Definition: ShapeModel.h:62
Isis::ShapeModel::hasIntersection
bool hasIntersection()
Returns intersection status.
Definition: ShapeModel.cpp:368
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
QVector
This is free and unencumbered software released into the public domain.
Definition: Calculator.h:18
Isis::Target
This class is used to create and store valid Isis targets.
Definition: Target.h:63
Isis::EllipsoidShape::isDEM
bool isDEM() const
Indicates that this shape model is not from a DEM.
Definition: EllipsoidShape.cpp:84
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::ShapeModel::normal
std::vector< double > normal()
Returns the local surface normal at the current intersection point.
Definition: ShapeModel.cpp:401
Isis::Angle::radians
double radians() const
Convert an angle to a double.
Definition: Angle.h:226