Isis 3.0 Programmer Reference
Back | Home
EllipsoidShape.cpp
1 #include "EllipsoidShape.h"
2 
3 #include <QVector>
4 
5 #include <SpiceUsr.h>
6 #include <SpiceZfc.h>
7 #include <SpiceZmc.h>
8 
9 #include "Distance.h"
10 #include "IException.h"
11 #include "IString.h"
12 #include "Latitude.h"
13 #include "Longitude.h"
14 #include "NaifStatus.h"
15 #include "ShapeModel.h"
16 #include "SurfacePoint.h"
17 
18 using namespace std;
19 
20 namespace Isis {
21 
27  EllipsoidShape::EllipsoidShape(Target *target) : ShapeModel (target) {
28  setName("Ellipsoid");
29  }
30 
31 
38  setName("Ellipsoid");
39  }
40 
41 
45  bool EllipsoidShape::intersectSurface (std::vector<double> observerPos,
46  std::vector<double> lookDirection) {
47 
48  return (intersectEllipsoid(observerPos, lookDirection));
49  }
50 
51 
57  }
58 
59 
65  }
66 
67 
75  bool EllipsoidShape::isDEM() const {
76  return false;
77  }
78 
79 
84 
85  if (!surfaceIntersection()->Valid() || !hasIntersection()) {
86  IString msg = "A valid intersection must be defined before computing the surface normal";
88  }
89 
90  // Get the coordinates of the current surface point
91  SpiceDouble pB[3];
92  pB[0] = surfaceIntersection()->GetX().kilometers();
93  pB[1] = surfaceIntersection()->GetY().kilometers();
94  pB[2] = surfaceIntersection()->GetZ().kilometers();
95 
96  // Get the radii of the ellipsoid
97  vector<Distance> radii = targetRadii();
98  double a = radii[0].kilometers();
99  double b = radii[1].kilometers();
100  double c = radii[2].kilometers();
101  vector<double> normal(3,0.);
102 
104  surfnm_c(a, b, c, pB, (SpiceDouble *) &normal[0]);
106 
107  setNormal(normal);
108  setHasNormal(true);
109  }
110 
111 
120 
121  std::vector<Distance> radii = targetRadii();
122 
123  double a = radii[0].kilometers();
124  double b = radii[1].kilometers();
125  double c = radii[2].kilometers();
126 
127  double rlat = lat.radians();
128  double rlon = lon.radians();
129 
130  double xyradius = a * b / sqrt(pow(b * cos(rlon), 2) +
131  pow(a * sin(rlon), 2));
132  const double &radius = xyradius * c / sqrt(pow(c * cos(rlat), 2) +
133  pow(xyradius * sin(rlat), 2));
134 
135  return Distance(radius, Distance::Kilometers);
136  }
137 
138 }
void calculateEllipsoidalSurfaceNormal()
Calculates the ellipsoidal surface normal.
Definition: ShapeModel.cpp:81
std::vector< double > normal()
Returns the local surface normal at the current intersection point.
Definition: ShapeModel.cpp:342
void calculateLocalNormal(QVector< double * > cornerNeighborPoints)
Calculate the local surface normal of the current intersection point.
double radians() const
Convert an angle to a double.
Definition: Angle.h:239
void setNormal(const std::vector< double >)
Sets the normal for the currect intersection point.
Definition: ShapeModel.cpp:398
bool hasIntersection()
Returns intersection status.
Definition: ShapeModel.cpp:309
void calculateSurfaceNormal()
Calculate the surface normal of the current intersection point.
virtual void calculateDefaultNormal()
Calculate the default normal of the current intersection point.
This class is designed to encapsulate the concept of a Latitude.
Definition: Latitude.h:59
The distance is being specified in kilometers.
Definition: Distance.h:58
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:154
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:376
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:208
double kilometers() const
Get the displacement in kilometers.
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
bool isDEM() const
Indicates that this shape model is not from a DEM.
Distance localRadius(const Latitude &lat, const Longitude &lon)
Get the local radius for a point on the surface.
This class is used to create and store valid Isis3 targets.
Definition: Target.h:63
Define shapes and provide utilities for Isis3 targets.
Definition: ShapeModel.h:68
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:99
Adds specific functionality to C++ strings.
Definition: IString.h:179
void setName(QString name)
Sets the shape name.
Definition: ShapeModel.cpp:443
void setHasNormal(bool status)
Sets the flag to indicate whether this ShapeModel has a surface normal.
Definition: ShapeModel.cpp:492
bool intersectSurface(std::vector< double > observerPos, std::vector< double > lookDirection)
Intersect the shape model.
SurfacePoint * surfaceIntersection() const
Returns the surface intersection for this ShapeModel.
Definition: ShapeModel.cpp:299
Unless noted otherwise, the portions of Isis written by the USGS are public domain.

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:17:42