Isis 3 Programmer Reference
EllipsoidShape.cpp
1 #include "EllipsoidShape.h"
2 
3 #include <QVector>
4 
5 
6 #include <SpiceUsr.h>
7 #include <SpiceZfc.h>
8 #include <SpiceZmc.h>
9 
10 #include "Distance.h"
11 #include "IException.h"
12 #include "IString.h"
13 #include "Latitude.h"
14 #include "Longitude.h"
15 #include "NaifStatus.h"
16 #include "ShapeModel.h"
17 #include "SurfacePoint.h"
18 
19 using namespace std;
20 
21 namespace Isis {
22 
28  EllipsoidShape::EllipsoidShape(Target *target) : ShapeModel (target) {
29  setName("Ellipsoid");
30  }
31 
32 
39  setName("Ellipsoid");
40  }
41 
42 
46  bool EllipsoidShape::intersectSurface (std::vector<double> observerPos,
47  std::vector<double> lookDirection) {
48 
49  return (intersectEllipsoid(observerPos, lookDirection));
50  }
51 
52 
57  QVector <double *> points;
58  calculateLocalNormal(points);
59  }
60 
61 
66  QVector <double *> points;
67  calculateLocalNormal(points);
68  }
69 
70 
78  bool EllipsoidShape::isDEM() const {
79  return false;
80  }
81 
82 
103 
104  if (!surfaceIntersection()->Valid() || !hasIntersection()) {
105  IString msg = "A valid intersection must be defined before computing the surface normal";
107  }
108 
109  // Get the coordinates of the current surface point
110  SpiceDouble pB[3];
111  pB[0] = surfaceIntersection()->GetX().kilometers();
112  pB[1] = surfaceIntersection()->GetY().kilometers();
113  pB[2] = surfaceIntersection()->GetZ().kilometers();
114 
115  // Get the radii of the ellipsoid
116  vector<Distance> radii = targetRadii();
117  double a = radii[0].kilometers();
118  double b = radii[1].kilometers();
119  double c = radii[2].kilometers();
120 
121  vector<double> normal(3,0.);
123  surfnm_c(a, b, c, pB, (SpiceDouble *) &normal[0]);
125 
126  setNormal(normal);
127  setHasNormal(true);
128  }
129 
130 
139 
140  std::vector<Distance> radii = targetRadii();
141 
142  double a = radii[0].kilometers();
143  double b = radii[1].kilometers();
144  double c = radii[2].kilometers();
145 
146  double rlat = lat.radians();
147  double rlon = lon.radians();
148 
149  double xyradius = a * b / sqrt(pow(b * cos(rlon), 2) +
150  pow(a * sin(rlon), 2));
151  const double &radius = xyradius * c / sqrt(pow(c * cos(rlat), 2) +
152  pow(xyradius * sin(rlat), 2));
153 
154  return Distance(radius, Distance::Kilometers);
155  }
156 
157 }
std::vector< double > normal()
Returns the local surface normal at the current intersection point.
Definition: ShapeModel.cpp:395
void setNormal(const std::vector< double >)
Sets the normal for the currect intersection point.
Definition: ShapeModel.cpp:481
double radians() const
Convert an angle to a double.
Definition: Angle.h:243
bool hasIntersection()
Returns intersection status.
Definition: ShapeModel.cpp:362
void calculateSurfaceNormal()
Calculate the surface normal of the current intersection point.
virtual void calculateDefaultNormal()
Calculate the default normal of the current intersection point.
Namespace for the standard library.
This class is designed to encapsulate the concept of a Latitude.
Definition: Latitude.h:63
The distance is being specified in kilometers.
Definition: Distance.h:58
SurfacePoint * surfaceIntersection() const
Returns the surface intersection for this ShapeModel.
Definition: ShapeModel.cpp:352
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
Distance measurement, usually in meters.
Definition: Distance.h:47
std::vector< Distance > targetRadii() const
Returns the radii of the body in km.
Definition: ShapeModel.cpp:459
This class is designed to encapsulate the concept of a Longitude.
Definition: Longitude.h:52
EllipsoidShape()
Initialize the EllipsoidShape.
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:261
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
Distance localRadius(const Latitude &lat, const Longitude &lon)
Get the local radius for a point on the surface.
bool isDEM() const
Indicates that this shape model is not from a DEM.
This class is used to create and store valid Isis3 targets.
Definition: Target.h:76
Define shapes and provide utilities for Isis3 targets.
Definition: ShapeModel.h:78
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:43
Isis exception class.
Definition: IException.h:107
Adds specific functionality to C++ strings.
Definition: IString.h:181
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void setName(QString name)
Sets the shape name.
Definition: ShapeModel.cpp:526
void setHasNormal(bool status)
Sets the flag to indicate whether this ShapeModel has a surface normal.
Definition: ShapeModel.cpp:575
double kilometers() const
Get the displacement in kilometers.
bool intersectSurface(std::vector< double > observerPos, std::vector< double > lookDirection)
Intersect the shape model.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
void calculateLocalNormal(QVector< double *> cornerNeighborPoints)
Calculate the local surface normal of the current intersection point.