29 #define MAX(x,y) (((x) > (y)) ? (x) : (y)) 37 EquatorialCylindricalShape::EquatorialCylindricalShape(
Target *target,
Pvl &pvl) :
39 setName(
"EquatorialCylindricalShape");
46 if (!
demCube()->hasTable(
"ShapeModelStatistics")) {
47 QString msg =
"The input cube references a ShapeModel that has " 48 "not been updated for the new ray tracing algorithm. All DEM " 49 "files must now be padded at the poles and contain a " 50 "ShapeModelStatistics table defining their minimum and maximum " 51 "radii values. The demprep program should be used to prepare the " 52 "DEM before you can run this program. There is more information " 53 "available in the documentation of the demprep program.";
90 vector<double> observerLookVectorToTarget) {
102 SpiceDouble plat, plon, pradius;
114 SpiceDouble ulookB[3];
115 ulookB[0] = observerLookVectorToTarget[0];
116 ulookB[1] = observerLookVectorToTarget[1];
117 ulookB[2] = observerLookVectorToTarget[2];
118 vhat_c(ulookB, ulookB);
122 SpiceDouble observer[3];
123 observer[0] = observerBodyFixedPos[0];
124 observer[1] = observerBodyFixedPos[1];
125 observer[2] = observerBodyFixedPos[2];
127 SpiceDouble negobserver[3];
128 vminus_c(observer, negobserver);
130 double psi0 = vsep_c(negobserver, ulookB);
135 if (psi0 >
PI / 2.0) {
150 vperp_c(&observer, &ulookB, perp);
152 vsub_c(&observer, &perp, v);
153 double dot = vdot_c(ulookB, v);
154 qDebug() <<
"dot = " << dot;
173 double observerdist = vnorm_c(observer);
174 double cospsi0 = cos(psi0);
175 tvec[0] = observer[0] + observerdist * cospsi0 * ulookB[0];
176 tvec[1] = observer[1] + observerdist * cospsi0 * ulookB[1];
177 tvec[2] = observer[2] + observerdist * cospsi0 * ulookB[2];
179 double tlen = vnorm_c(tvec);
182 double radiusDiff = maxRadiusMetersSquared - tlen * tlen;
185 if (radiusDiff >= 0.0) {
186 radiusDiff = sqrt(radiusDiff);
193 double d0 = observerdist * cospsi0 - radiusDiff;
194 double dm = observerdist * cospsi0 + radiusDiff;
199 g1[0] = observer[0] + d0 * ulookB[0];
200 g1[1] = observer[1] + d0 * ulookB[1];
201 g1[2] = observer[2] + d0 * ulookB[2];
203 double g1len = vnorm_c(g1);
204 SpiceDouble g1lat, g1lon, g1radius;
205 reclat_c(g1, &g1radius, &g1lon, &g1lat);
209 if (g1lon < 0.0) g1lon += 360.0;
211 SpiceDouble negg1[3];
214 double psi1 = vsep_c(negg1, ulookB);
232 double tolerance = 3
E-8 * a;
247 double psi2 = psi1 + dalpha;
250 double dd = g1len * sin(dalpha) / sin(
PI - psi2);
257 if (dd < tolerance) {
266 g2[0] = observer[0] + d * ulookB[0];
267 g2[1] = observer[1] + d * ulookB[1];
268 g2[2] = observer[2] + d * ulookB[2];
270 double g2len = vnorm_c(g2);
273 SpiceDouble g2lat, g2lon, g2radius;
274 reclat_c(g2, &g2radius, &g2lon, &g2lat);
279 if (g2lon < 0.0) g2lon += 360.0;
299 while (it < maxit && !done) {
304 if ((g2len * r1 / r2 - g1len) == 0.0) {
311 double v = (r1 - g1len) / (g2len * r1 / r2 - g1len);
312 pB[0] = g1[0] + v * dd * ulookB[0];
313 pB[1] = g1[1] + v * dd * ulookB[1];
314 pB[2] = g1[2] + v * dd * ulookB[2];
316 reclat_c(pB, &pradius, &plon, &plat);
319 if (plon < 0.0) plon += 360.0;
321 if (plon > 360.0) plon -= 360.0;
331 palt = plen - pradius;
335 if (palt > tolerance) {
347 else if (palt < -tolerance) {
365 if (!done && it >= maxit) {
390 SpiceDouble intersectionPoint[3];
394 surfpt_c(&observerBodyFixedPos[0], &observerLookVectorToTarget[0], plen, plen, plen,
395 intersectionPoint, &found);
~EquatorialCylindricalShape()
Destructor for Isis3 Equatorial Cylindrical shape model.
const double PI
The mathematical constant PI.
bool hasIntersection()
Returns intersection status.
Namespace for the standard library.
This class is designed to encapsulate the concept of a Latitude.
The distance is being specified in kilometers.
SurfacePoint * surfaceIntersection() const
Returns the surface intersection for this ShapeModel.
double kilometers() const
Get the distance in kilometers.
Distance measurement, usually in meters.
std::vector< Distance > targetRadii() const
Returns the radii of the body in km.
void setHasIntersection(bool b)
Sets the flag to indicate whether this ShapeModel has an intersection.
This class is designed to encapsulate the concept of a Longitude.
bool intersectSurface(std::vector< double > observerPos, std::vector< double > lookDirection)
Finds the surface intersection point.
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
Define shapes and provide utilities for targets stored as Isis3 maps.
#define _FILEINFO_
Macro for the filename and line number.
A type of error that could only have occurred due to a mistake on the user's part (e...
bool IsSpecial(const double d)
Returns if the input pixel is special.
Container for cube-like labels.
const double E
Sets some basic constants for use in ISIS programming.
This class is used to create and store valid Isis3 targets.
const double DEG2RAD
Multiplier for converting from degrees to radians.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Cube * demCube()
Returns the cube defining the shape model.
Class for storing Table blobs information.
Distance localRadius(const Latitude &lat, const Longitude &lon)
Gets the radius from the DEM, if we have one.
Distance * m_minRadius
Minimum radius value in DEM file.
void FromNaifArray(const double naifValues[3])
A naif array is a c-style array of size 3.
double demScale()
Return the scale of the DEM shape, in pixels per degree.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Namespace for ISIS/Bullet specific routines.
bool intersectSurface(std::vector< double > observerPos, std::vector< double > lookDirection)
Find the intersection point with the DEM.
void setName(QString name)
Sets the shape name.
const double RAD2DEG
Multiplier for converting from radians to degrees.
Distance * m_maxRadius
Maximum radius value in DEM file.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
T MAX(const T &A, const T &B)
Implement templatized MAX fumnction.