32 RadarGroundMap::RadarGroundMap(Camera *parent, Radar::LookDirection ldir,
34 CameraGroundMap(parent) {
36 p_lookDirection = ldir;
37 p_waveLength = waveLength;
48 double et1 = p_camera->Spice::cacheStartTime().Et();
49 double et2 = p_camera->Spice::cacheEndTime().Et();
50 p_timeTolerance = (et2 - et1) / p_camera->Lines() / 20.0;
68 std::vector<double> Ssc(6);
70 vequ_c((SpiceDouble *) & (spaceCraft->
Coordinate()[0]), &Ssc[0]);
71 vequ_c((SpiceDouble *) & (spaceCraft->
Velocity()[0]), &Ssc[3]);
74 std::vector<double> bfSsc(6);
78 std::vector<double> Vsc(3);
79 std::vector<double> Xsc(3);
80 vequ_c(&bfSsc[0], (SpiceDouble *) & (Xsc[0]));
81 vequ_c(&bfSsc[3], (SpiceDouble *) & (Vsc[0]));
89 dp = vdot_c(&Xsc[0], i);
90 SpiceDouble p[3], q[3];
92 vsub_c(&Xsc[0], p, q);
100 p_camera->
radii(radii);
103 SpiceDouble lat = DBL_MAX;
104 SpiceDouble lon = DBL_MAX;
107 slantRangeSqr = slantRangeSqr * slantRangeSqr;
118 bool useSlopeEqn =
false;
120 bool success =
Iterate(R,slantRangeSqr,c,r,X,lat,lon,Xsc,useSlopeEqn,slope);
125 success =
Iterate(R,slantRangeSqr,c,r,X,lat,lon,Xsc,useSlopeEqn,slope);
128 if(!success)
return false;
132 while(lon < 0.0) lon += 360.0;
135 std::vector<double> lookB;
137 lookB[0] = X[0] - Xsc[0];
138 lookB[1] = X[1] - Xsc[1];
139 lookB[2] = X[2] - Xsc[2];
141 std::vector<double> lookJ = bodyFrame->
J2000Vector(lookB);
145 SpiceDouble unitLookC[3];
146 vhat_c(&lookC[0], unitLookC);
148 return p_camera->Sensor::SetUniversalGround(lat, lon);
160 const SpiceDouble r[], SpiceDouble X[], SpiceDouble &lat,
161 SpiceDouble &lon,
const std::vector<double> &Xsc,
162 const bool &useSlopeEqn,
const double &slope) {
166 SpiceDouble lastR = DBL_MAX;
171 double normXsc = vnorm_c(&Xsc[0]);
172 double alpha = (R * R - slantRangeSqr - normXsc * normXsc) /
173 (2.0 * vdot_c(&Xsc[0], c));
175 double arg = slantRangeSqr - alpha * alpha;
176 if(arg < 0.0)
return false;
178 double beta = sqrt(arg);
179 if(p_lookDirection == Radar::Left) beta *= -1.0;
181 SpiceDouble alphac[3], betar[3];
182 vscl_c(alpha, c, alphac);
183 vscl_c(beta, r, betar);
185 vadd_c(alphac, betar, alphac);
186 vadd_c(&Xsc[0], alphac, X);
190 reclat_c(X, &R, &lon, &lat);
202 while(fabs(R - lastR) > p_tolerance && iter < 100);
204 if(fabs(R - lastR) > p_tolerance)
return false;
219 if(!localRadius.isValid()) {
236 if(!surfacePoint.Valid())
return false;
242 double et1 = p_camera->Spice::cacheStartTime().Et();
243 p_camera->Sensor::setTime(et1);
244 double xv1 = ComputeXv(X);
247 double et2 = p_camera->Spice::cacheEndTime().Et();
248 p_camera->Sensor::setTime(et2);
249 double xv2 = ComputeXv(X);
252 if((xv1 < 0.0) && (xv2 < 0.0))
return false;
253 if((xv1 > 0.0) && (xv2 > 0.0))
return false;
256 double fl, fh, xl, xh;
271 for(
int j = 0; j < 30; j++) {
273 double etGuess = xl + (xh - xl) * fl / (fl - fh);
277 p_camera->Sensor::setTime(etGuess);
278 double fGuess = ComputeXv(X);
283 delTime = xl - etGuess;
288 delTime = xh - etGuess;
294 if((fabs(delTime) <= p_timeTolerance) || (fGuess == 0.0)) {
299 std::vector<double> Ssc(6);
302 vequ_c((SpiceDouble *) & (spaceCraft->
Coordinate()[0]), &Ssc[0]);
303 vequ_c((SpiceDouble *) & (spaceCraft->
Velocity()[0]), &Ssc[3]);
304 std::vector<double> bfSsc(6);
308 std::vector<double> Vsc(3);
309 std::vector<double> Xsc(3);
310 vequ_c(&bfSsc[0], (SpiceDouble *) & (Xsc[0]));
311 vequ_c(&bfSsc[3], (SpiceDouble *) & (Vsc[0]));
321 SpiceDouble vout1[3];
322 SpiceDouble vout2[3];
324 vsub_c(X, &Xsc[0], vout1);
325 vcrss_c(&Vsc[0], &Xsc[0], vout2);
326 dp = vdot_c(vout1, vout2);
327 if(dp > 0.0 && p_lookDirection == Radar::Left)
return false;
328 if(dp < 0.0 && p_lookDirection == Radar::Right)
return false;
329 if(dp == 0.0)
return false;
334 std::vector<double> lookB;
336 lookB[0] = X[0] - Xsc[0];
337 lookB[1] = X[1] - Xsc[1];
338 lookB[2] = X[2] - Xsc[2];
340 std::vector<double> lookJ = bodyFrame->
J2000Vector(lookB);
344 SpiceDouble unitLookC[3];
345 vhat_c(&lookC[0], unitLookC);
354 return p_camera->Sensor::SetGround(surfacePoint,
true);
378 double *cudy,
bool test) {
390 std::vector<double> sJ(6);
392 vequ_c((SpiceDouble *) & (spaceCraft->
Coordinate()[0]), &sJ[0]);
393 vequ_c((SpiceDouble *) & (spaceCraft->
Velocity()[0]), &sJ[3]);
402 vequ_c(&p_sB[0], PsB);
403 vequ_c(&p_sB[3], VsB);
406 vsub_c(X, PsB, &p_lookB[0]);
414 QString msg =
"Back of planet test is not enabled for Radar images";
422 double RadarGroundMap::ComputeXv(SpiceDouble X[3]) {
429 std::vector<double> Ssc(6);
430 vequ_c((SpiceDouble *) & (spaceCraft->
Coordinate()[0]), &Ssc[0]);
431 vequ_c((SpiceDouble *) & (spaceCraft->
Velocity()[0]), &Ssc[3]);
434 std::vector<double> bfSsc(6);
438 std::vector<double> Vsc(3);
439 std::vector<double> Xsc(3);
440 vequ_c(&bfSsc[0], &Xsc[0]);
441 vequ_c(&bfSsc[3], &Vsc[0]);
444 SpiceDouble lookB[3];
445 vsub_c(&Xsc[0], X, lookB);
451 double xv = -2.0 * vdot_c(lookB, &Vsc[0]) / (vnorm_c(lookB) *
WaveLength());
478 double *dx,
double *dy) {
482 std::vector <double> d_lookJ(6);
484 vequ_c(&(instPos->
VelocityPartial(varType, coefIndex))[0], &d_lookJ[3]);
513 double *dx,
double *dy) {
This class defines a body-fixed surface point.
virtual bool SetFocalPlane(const double ux, const double uy, const double uz)
Compute ground position from slant range.
double p_focalPlaneY
Camera's y focal plane coordinate.
double p_focalPlaneX
Camera's x focal plane coordinate.
const double PI
The mathematical constant PI.
double p_groundDopplerFreq
units are hertz
SpiceRotation * bodyRotation() const
Accessor method for the body rotation.
Namespace for the standard library.
double p_slantRange
units are km
This class is designed to encapsulate the concept of a Latitude.
virtual bool SetGround(const Latitude &lat, const Longitude &lon)
Compute undistorted focal plane coordinate from ground position.
double p_rangeSigma
Scaling factor to convert meters to focal plane coord.
std::vector< double > CoordinatePartial(SpicePosition::PartialType partialVar, int coeffIndex)
Set the coefficients of a polynomial fit to each of the three coordinates of the position vector for ...
This error is for when a programmer made an API call that was illegal.
double kilometers() const
Get the distance in kilometers.
Distance measurement, usually in meters.
Distance LocalRadius() const
Returns the local radius at the intersection point.
This class is designed to encapsulate the concept of a Longitude.
void SetFocalLength(double v)
Sets the focal length.
void instrumentPosition(double p[3]) const
Returns the spacecraft position in body-fixed frame km units.
std::vector< double > ReferenceVector(const std::vector< double > &jVec)
Given a direction vector in J2000, return a reference frame direction.
Target * target() const
Returns a pointer to the target object.
double p_dopplerSigma
Scaling factor to convert hertz to focal plane coord.
#define _FILEINFO_
Macro for the filename and line number.
const std::vector< double > & Coordinate()
Return the current J2000 position.
bool Iterate(SpiceDouble &R, const double &slantRangeSqr, const SpiceDouble c[], const SpiceDouble r[], SpiceDouble X[], SpiceDouble &lat, SpiceDouble &lon, const std::vector< double > &Xsc, const bool &useSlopeEqn, const double &slope)
Iteration loop for computing ground position from slant range.
ShapeModel * shape() const
Return the shape.
Obtain SPICE rotation information for a body.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
double WaveLength()
Return the wavelength.
std::vector< double > J2000Vector(const std::vector< double > &rVec)
Given a direction vector in the reference frame, return a J2000 direction.
void ToNaifArray(double naifOutput[3]) const
A naif array is a c-style array of size 3.
std::vector< double > VelocityPartial(SpicePosition::PartialType partialVar, int coeffIndex)
Compute the derivative of the velocity with respect to the specified variable.
virtual void setSurfacePoint(const SurfacePoint &surfacePoint)
Set surface intersection point.
double p_groundSlantRange
units are km
virtual bool GetdXYdPoint(std::vector< double > d_lookB, double *dx, double *dy)
Compute derivative of focal plane coordinate w/r to ground point from ground position using current S...
Obtain SPICE position information for a body.
const std::vector< double > & Velocity()
Return the current J2000 velocity.
Namespace for ISIS/Bullet specific routines.
SpiceRotation * instrumentRotation() const
Accessor method for the instrument rotation.
virtual bool GetXY(const SurfacePoint &spoint, double *cudx, double *cudy, bool test=false)
Compute undistorted focal plane coordinate from ground position using current Spice from SetImage cal...
virtual bool GetdXYdPosition(const SpicePosition::PartialType varType, int coefIndex, double *cudx, double *cudy)
Compute derivative w/r to position of focal plane coordinate from ground position using current Spice...
double kilometers() const
Get the displacement in kilometers.
void radii(Distance r[3]) const
Returns the radii of the body in km.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.