File failed to load: https://isis.astrogeology.usgs.gov/9.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
EllipsoidShape.cpp
1
5
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
25using namespace std;
26
27namespace Isis {
28
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
65
66
71 QVector <double *> points;
73
75 }
76
77
85 bool EllipsoidShape::isDEM() const {
86 return false;
87 }
88
89
110
111 if (!surfaceIntersection()->Valid() || !hasIntersection()) {
112 IString msg = "A valid intersection must be defined before computing the surface normal";
113 throw IException(IException::Programmer, msg, _FILEINFO_);
114 }
115
116 // Get the coordinates of the current surface point
117 SpiceDouble pB[3];
118 pB[0] = surfaceIntersection()->GetX().kilometers();
119 pB[1] = surfaceIntersection()->GetY().kilometers();
120 pB[2] = surfaceIntersection()->GetZ().kilometers();
121
122 // Get the radii of the ellipsoid
123 vector<Distance> radii = targetRadii();
124 double a = radii[0].kilometers();
125 double b = radii[1].kilometers();
126 double c = radii[2].kilometers();
127
128 vector<double> normal(3,0.);
130 surfnm_c(a, b, c, pB, (SpiceDouble *) &normal[0]);
132
134 setHasLocalNormal(true);
135 }
136
137
146
147 std::vector<Distance> radii = targetRadii();
148
149 double a = radii[0].kilometers();
150 double b = radii[1].kilometers();
151 double c = radii[2].kilometers();
152
153 double rlat = lat.radians();
154 double rlon = lon.radians();
155
156 double xyradius = a * b / sqrt(pow(b * cos(rlon), 2) +
157 pow(a * sin(rlon), 2));
158 const double &radius = xyradius * c / sqrt(pow(c * cos(rlat), 2) +
159 pow(xyradius * sin(rlat), 2));
160
161 return Distance(radius, Distance::Kilometers);
162 }
163
164}
double radians() const
Convert an angle to a double.
Definition Angle.h:226
double kilometers() const
Get the displacement in kilometers.
Distance measurement, usually in meters.
Definition Distance.h:34
@ Kilometers
The distance is being specified in kilometers.
Definition Distance.h:45
EllipsoidShape()
Initialize the EllipsoidShape.
bool intersectSurface(std::vector< double > observerPos, std::vector< double > lookDirection)
Intersect the shape model.
bool isDEM() const
Indicates that this shape model is not from a DEM.
void calculateLocalNormal(QVector< double * > cornerNeighborPoints)
Calculate the local surface normal of the current intersection point.
void calculateSurfaceNormal()
Calculate the surface normal of the current intersection point.
Distance localRadius(const Latitude &lat, const Longitude &lon)
Get the local radius for a point on the surface.
virtual void calculateDefaultNormal()
Calculate the default normal of the current intersection point.
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
Adds specific functionality to C++ strings.
Definition IString.h:165
This class is designed to encapsulate the concept of a Latitude.
Definition Latitude.h:51
This class is designed to encapsulate the concept of a Longitude.
Definition Longitude.h:40
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
bool hasIntersection()
Returns intersection status.
void setNormal(const std::vector< double >)
Sets the surface normal for the currect intersection point.
void setLocalNormal(const std::vector< double >)
Sets the local normal for the currect intersection point.
virtual SurfacePoint * surfaceIntersection() const
Returns the surface intersection for this ShapeModel.
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...
virtual std::vector< double > normal()
Returns the surface normal at the current intersection point.
virtual std::vector< double > localNormal()
Returns the local surface normal at the current intersection point.
std::vector< Distance > targetRadii() const
Returns the radii of the body in km.
void setHasLocalNormal(bool status)
Sets the flag to indicate whether this ShapeModel has a local normal.
ShapeModel()
Default constructor creates ShapeModel object, initializing name to an empty string,...
void setName(QString name)
Sets the shape name.
This class is used to create and store valid Isis targets.
Definition Target.h:63
This is free and unencumbered software released into the public domain.
Definition Calculator.h:18
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.