38 CameraGroundMap::CameraGroundMap(Camera *parent) {
40 p_camera->SetGroundMap(
this);
55 bool CameraGroundMap::SetFocalPlane(
const double ux,
const double uy,
57 NaifStatus::CheckErrors();
64 SpiceDouble unitLookC[3];
65 vhat_c(lookC, unitLookC);
67 NaifStatus::CheckErrors();
69 bool result = p_camera->SetLookDirection(unitLookC);
81 if (p_camera->target()->shape()->name() ==
"Plane") {
85 if (radius < 0.0) radius = 0.0;
87 LookCtoFocalPlaneXY();
92 Distance radius(p_camera->LocalRadius(lat, lon));
93 if (radius.isValid()) {
94 if(p_camera->Sensor::SetGround(
SurfacePoint(lat, lon, radius))) {
95 LookCtoFocalPlaneXY();
105 void CameraGroundMap::LookCtoFocalPlaneXY() {
107 p_camera->Sensor::LookDirection(lookC);
110 double focalLength = p_camera->DistortionMap()->UndistortedFocalPlaneZ();
111 double scale = focalLength / lookC[2];
113 p_focalPlaneX = lookC[0] * scale;
114 p_focalPlaneY = lookC[1] * scale;
126 if(p_camera->Sensor::SetGround(surfacePoint)) {
127 LookCtoFocalPlaneXY();
146 bool CameraGroundMap::GetXY(
const SurfacePoint &point,
double *cudx,
double *cudy) {
154 if(p_camera->target()->isSky()) {
167 std::vector<double> sB = bodyRot->
ReferenceVector(p_camera->instrumentPosition()->Coordinate());
168 std::vector<double> lookB(3);
169 for(
int ic = 0; ic < 3; ic++) lookB[ic] = pB[ic] - sB[ic];
173 double upsB[3], upB[3], dist;
174 vminus_c((SpiceDouble *) &lookB[0], upsB);
175 unorm_c(upsB, upsB, &dist);
176 unorm_c(pB, upB, &dist);
177 double angle = vdot_c(upB, upsB);
182 else if(angle < -1) {
186 emission = acos(angle) * 180.0 /
Isis::PI;
188 if(fabs(emission) > 90.)
return false;
192 p_lookJ = p_camera->bodyRotation()->J2000Vector(lookB);
193 std::vector <double> lookC(3);
197 double fl = p_camera->DistortionMap()->UndistortedFocalPlaneZ();
199 *cudx = lookC[0] * fl / lookC[2];
200 *cudy = lookC[1] * fl / lookC[2];
220 bool CameraGroundMap::GetXY(
const double lat,
const double lon,
221 const double radius,
double *cudx,
double *cudy) {
224 Distance(radius, Distance::Meters));
225 return GetXY(spoint, cudx, cudy);
243 bool CameraGroundMap::GetdXYdPosition(
const SpicePosition::PartialType varType,
int coefIndex,
244 double *dx,
double *dy) {
249 double fl = p_camera->DistortionMap()->UndistortedFocalPlaneZ();
253 std::vector <double> lookC(3);
259 for(
int j = 0; j < 3; j++) d_lookJ[j] *= -1.0;
261 *dx = fl * DQuotient(lookC, d_lookC, 0);
262 *dy = fl * DQuotient(lookC, d_lookC, 1);
281 double *dx,
double *dy) {
286 double fl = p_camera->DistortionMap()->UndistortedFocalPlaneZ();
290 std::vector <double> lookC(3);
293 std::vector<double> d_lookC = instRot->
ToReferencePartial(p_lookJ, varType, coefIndex);
294 *dx = fl * DQuotient(lookC, d_lookC, 0);
295 *dy = fl * DQuotient(lookC, d_lookC, 1);
312 bool CameraGroundMap::GetdXYdPoint(std::vector<double> d_lookB,
double *dx,
double *dy) {
317 double fl = p_camera->DistortionMap()->UndistortedFocalPlaneZ();
321 std::vector <double> lookC(3);
325 std::vector<double> d_lookJ = bodyRot->
J2000Vector(d_lookB);
328 *dx = fl * DQuotient(lookC, d_lookC, 0);
329 *dy = fl * DQuotient(lookC, d_lookC, 1);
343 std::vector<double> CameraGroundMap::PointPartial(
SurfacePoint spoint, PartialType wrt) {
346 double sinLon = sin(rlon);
347 double cosLon = cos(rlon);
348 double sinLat = sin(rlat);
349 double cosLat = cos(rlat);
352 std::vector<double> v(3);
353 if(wrt == WRT_Latitude) {
354 v[0] = -radkm * sinLat * cosLon;
355 v[1] = -radkm * sinLon * sinLat;
356 v[2] = radkm * cosLat;
358 else if(wrt == WRT_Longitude) {
359 v[0] = -radkm * cosLat * sinLon;
360 v[1] = radkm * cosLat * cosLon;
364 v[0] = cosLon * cosLat;
365 v[1] = sinLon * cosLat;
385 double CameraGroundMap::DQuotient(std::vector<double> &look,
386 std::vector<double> &dlook,
388 return (look[2] * dlook[index] - look[index] * dlook[2]) /