27#include "CubeManager.h"
29#include "EllipsoidShape.h"
31#include "IException.h"
32#include "Interpolator.h"
36#include "NaifStatus.h"
38#include "Projection.h"
41#include "SurfacePoint.h"
44#include "UniqueIOCachingAlgorithm.h"
82 demCubeFile = (QString) kernels[
"ElevationModel"];
85 demCubeFile = (QString) kernels[
"ShapeModel"];
144 vector<double> lookDirection) {
150 if (!ellipseIntersected) {
155 static const int maxit = 100;
157 double dX, dY, dZ, dist2;
165 SpiceDouble currentIntersectPt[3];
166 SpiceDouble newIntersectPt[3];
174 double tol2 = tol * tol;
188 double t = newIntersectPt[0] * newIntersectPt[0] +
189 newIntersectPt[1] * newIntersectPt[1];
191 latDD = atan2(newIntersectPt[2], sqrt(t)) *
RAD2DEG;
192 lonDD = atan2(newIntersectPt[1], newIntersectPt[0]) *
RAD2DEG;
210 memcpy(currentIntersectPt, newIntersectPt, 3 *
sizeof(
double));
214 surfpt_c((SpiceDouble *) &observerPos[0], &lookDirection[0], r, r, r, newIntersectPt,
215 (SpiceBoolean*) &status);
232 dX = currentIntersectPt[0] - newIntersectPt[0];
233 dY = currentIntersectPt[1] - newIntersectPt[1];
234 dZ = currentIntersectPt[2] - newIntersectPt[2];
235 dist2 = (dX*dX + dY*dY + dZ*dZ) * 1000 * 1000;
308 IString msg =
"A valid intersection must be defined before computing the surface normal";
320 double a = radii[0].kilometers();
321 double b = radii[1].kilometers();
322 double c = radii[2].kilometers();
324 vector<double>
normal(3,0.);
327 surfnm_c(a, b, c, pB, (SpiceDouble *) &
normal[0]);
369 std::vector<SpiceDouble>
normal(3);
370 if (neighborPoints.isEmpty()) {
378 double topMinusBottom[3];
379 vsub_c(neighborPoints[0], neighborPoints[1], topMinusBottom);
380 double rightMinusLeft[3];
381 vsub_c(neighborPoints[3], neighborPoints [2], rightMinusLeft);
384 ucrss_c(topMinusBottom, rightMinusLeft, (SpiceDouble *) &
normal[0]);
388 unorm_c((SpiceDouble *) &
normal[0], (SpiceDouble *) &
normal[0], &mag);
404 double centerLookVect[3];
407 unorm_c(pB, centerLookVect, &mag);
408 double dotprod = vdot_c((SpiceDouble *) &
normal[0], centerLookVect);
410 vminus_c((SpiceDouble *) &
normal[0], (SpiceDouble *) &
normal[0]);
bool isValid() const
This indicates whether we have a legitimate angle stored or are in an unset, or invalid,...
double degrees() const
Get the angle in units of Degrees.
@ Degrees
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
IO Handler for Isis Cubes.
static Cube * Open(const QString &cubeFileName)
This method calls the method OpenCube() on the static instance.
Projection * m_demProj
The projection of the model.
Cube * m_demCube
The cube containing the model.
~DemShape()
Destroys the DemShape.
Interpolator * m_interp
Use bilinear interpolation from dem.
Portal * m_portal
Buffer used to read from the model.
Distance localRadius(const Latitude &lat, const Longitude &lon)
Gets the radius from the DEM, if we have one.
double demScale()
Return the scale of the DEM shape, in pixels per degree.
virtual void calculateDefaultNormal()
This method calculates the default normal (Ellipsoid for backwards compatability) for the DemShape.
DemShape()
Construct a DemShape object.
Cube * demCube()
Returns the cube defining the shape model.
bool isDEM() const
Indicates that this shape model is from a DEM.
void calculateLocalNormal(QVector< double * > cornerNeighborPoints)
This method calculates the local surface normal of the current intersection point.
double m_pixPerDegree
Scale of DEM file in pixels per degree.
void calculateSurfaceNormal()
This method calculates the surface normal of the current intersection point.
bool intersectSurface(std::vector< double > observerPos, std::vector< double > lookDirection)
Find the intersection point with the DEM.
double kilometers() const
Get the displacement in kilometers.
Distance measurement, usually in meters.
double kilometers() const
Get the distance in kilometers.
@ Meters
The distance is being specified in meters.
@ Programmer
This error is for when a programmer made an API call that was illegal.
Adds specific functionality to C++ strings.
This class is designed to encapsulate the concept of a Latitude.
This class is designed to encapsulate the concept of a Longitude.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Buffer for containing a two dimensional section of an image.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Contains multiple PvlContainers.
Container for cube-like labels.
@ Traverse
Search child objects.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
double resolution()
Convenience method to get pixel resolution (m/pix) at current intersection point.
void setHasNormal(bool status)
Sets the flag to indicate whether this ShapeModel has a surface normal.
bool hasIntersection()
Returns intersection status.
void setHasIntersection(bool b)
Sets the flag to indicate whether this ShapeModel has an intersection.
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.
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.
void ToNaifArray(double naifOutput[3]) const
A naif array is a c-style array of size 3.
void FromNaifArray(const double naifValues[3])
A naif array is a c-style array of size 3.
This class is used to create and store valid Isis targets.
This algorithm is designed for applications that jump around between a couple of spots in the cube wi...
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
bool IsSpecial(const double d)
Returns if the input pixel is special.
const double RAD2DEG
Multiplier for converting from radians to degrees.
Namespace for the standard library.