7 #include "CameraGroundMap.h"
15 #include "IException.h"
17 #include "Longitude.h"
18 #include "NaifStatus.h"
19 #include "SurfacePoint.h"
31 CameraGroundMap::CameraGroundMap(
Camera *parent) {
50 bool CameraGroundMap::SetFocalPlane(
const double ux,
const double uy,
const double uz) {
51 NaifStatus::CheckErrors();
58 SpiceDouble unitLookC[3];
59 vhat_c(lookC, unitLookC);
61 NaifStatus::CheckErrors();
63 bool result = p_camera->SetLookDirection(unitLookC);
77 if (p_camera->target()->shape()->name() ==
"Plane") {
81 if (radius < 0.0) radius = 0.0;
85 LookCtoFocalPlaneXY();
90 Distance radius(p_camera->LocalRadius(lat, lon));
92 if (p_camera->Sensor::SetGround(
SurfacePoint(lat, lon, radius))) {
93 LookCtoFocalPlaneXY();
106 void CameraGroundMap::LookCtoFocalPlaneXY() {
108 p_camera->Sensor::LookDirection(lookC);
111 double focalLength = p_camera->DistortionMap()->UndistortedFocalPlaneZ();
112 double scale = focalLength / lookC[2];
114 p_focalPlaneX = lookC[0] * scale;
115 p_focalPlaneY = lookC[1] * scale;
127 if (p_camera->Sensor::SetGround(surfacePoint)) {
128 LookCtoFocalPlaneXY();
153 double *cudy,
bool test) {
155 vector<double> pB(3);
161 if (p_camera->target()->isSky()) {
171 vector<double> sJ = p_camera->instrumentPosition()->Coordinate();
174 vector<double> lookJ(3);
175 for (
int ic = 0; ic < 3; ic++) {
176 lookJ[ic] = pJ[ic] - sJ[ic];
199 double upsB[3], upB[3], dist;
200 vminus_c((SpiceDouble *) &lookB[0], upsB);
201 unorm_c(upsB, upsB, &dist);
202 unorm_c((SpiceDouble *) &pB[0], upB, &dist);
203 double cosangle = vdot_c(upB, upsB);
208 else if (cosangle < -1) {
212 emission = acos(cosangle) * 180.0 /
Isis::PI;
215 if (fabs(emission) > 90.) {
223 vector<double> lookC(3);
227 double fl = p_camera->DistortionMap()->UndistortedFocalPlaneZ();
229 *cudx = lookC[0] * fl / lookC[2];
230 *cudy = lookC[1] * fl / lookC[2];
254 bool CameraGroundMap::GetXY(
const double lat,
const double lon,
255 const double radius,
double *cudx,
double *cudy) {
258 Distance(radius, Distance::Meters));
259 return GetXY(spoint, cudx, cudy);
279 bool CameraGroundMap::GetdXYdPosition(
const SpicePosition::PartialType varType,
int coefIndex,
280 double *dx,
double *dy) {
285 double fl = p_camera->DistortionMap()->UndistortedFocalPlaneZ();
289 vector<double> lookC(3);
295 for (
int j = 0; j < 3; j++) d_lookJ[j] *= -1.0;
297 *dx = fl * DQuotient(lookC, d_lookC, 0);
298 *dy = fl * DQuotient(lookC, d_lookC, 1);
319 double *dx,
double *dy) {
324 double fl = p_camera->DistortionMap()->UndistortedFocalPlaneZ();
328 vector<double> lookC(3);
334 *dx = fl * DQuotient(lookC, d_lookC, 0);
335 *dy = fl * DQuotient(lookC, d_lookC, 1);
355 double *dx,
double *dy) {
366 double fl = p_camera->DistortionMap()->UndistortedFocalPlaneZ();
371 vector<double> dlookJ = bodyRot->
toJ2000Partial(m_pB, varType, coefIndex);
372 vector<double> lookC(3);
373 vector<double> dlookC(3);
379 *dx = fl * DQuotient(lookC, dlookC, 0);
380 *dy = fl * DQuotient(lookC, dlookC, 1);
398 bool CameraGroundMap::GetdXYdPoint(vector<double> d_pB,
double *dx,
double *dy) {
403 double fl = p_camera->DistortionMap()->UndistortedFocalPlaneZ();
407 vector<double> lookC(3);
411 vector<double> d_lookJ = bodyRot->
J2000Vector(d_pB);
414 *dx = fl * DQuotient(lookC, d_lookC, 0);
415 *dy = fl * DQuotient(lookC, d_lookC, 1);
439 double sinLon = sin(rlon);
440 double cosLon = cos(rlon);
441 double sinLat = sin(rlat);
442 double cosLat = cos(rlat);
448 v[0] = cosLat * cosLon;
454 v[1] = cosLat * sinLon;
463 QString msg =
"Invalid partial type for this method";
464 throw IException(IException::Programmer, msg, _FILEINFO_);
511 double sinLon = sin(rlon);
512 double cosLon = cos(rlon);
513 double sinLat = sin(rlat);
514 double cosLat = cos(rlat);
518 if (wrt == WRT_Latitude) {
519 v[0] = -radkm * sinLat * cosLon;
520 v[1] = -radkm * sinLon * sinLat;
521 v[2] = radkm * cosLat;
523 else if (wrt == WRT_Longitude) {
524 v[0] = -radkm * cosLat * sinLon;
525 v[1] = radkm * cosLat * cosLon;
529 v[0] = cosLon * cosLat;
530 v[1] = sinLon * cosLat;
550 double CameraGroundMap::DQuotient(vector<double> &look,
551 vector<double> &dlook,
553 return (look[2] * dlook[index] - look[index] * dlook[2]) /