9#include "VimsGroundMap.h"
17#include "BasisFunction.h"
22#include "IException.h"
26#include "LeastSquares.h"
28#include "PolynomialBivariate.h"
29#include "Preference.h"
30#include "SpecialPixel.h"
53 IString msg =
"The Vims ground map does not understand cubes that "
54 "initially have more than 64 lines or 64 samples.";
55 throw IException(IException::Programmer, msg, _FILEINFO_);
123 QString stime = (QString) inst [
"NativeStartTime"];
124 QString intTime = stime.split(
".").first();
125 stime = stime.split(
".").last();
138 QString sampMode = QString((QString)inst [
"SamplingMode"]).toUpper();
141 int sampOffset = inst [
"XOffset"];
142 int lineOffset = inst [
"ZOffset"];
149 if (sampMode ==
"NORMAL") {
156 else if (sampMode ==
"HI-RES") {
166 string msg =
"Unsupported SamplingMode [" +
IString(sampMode) +
"]";
171 if (sampMode ==
"NORMAL") {
177 else if (sampMode ==
"HI-RES") {
186 string msg =
"Unsupported SamplingMode [" +
IString(sampMode) +
"]";
196 for (
int line = 0; line <
p_camera->ParentLines(); line++) {
210 for (
int samp = 0; samp <
p_camera->ParentSamples(); samp++) {
218 if (
p_camera->SetImage((
double) samp + 1, (
double)line + 1)) {
223 if (xyz[0] !=
Null && xyz[1] !=
Null && xyz[2] !=
Null) {
224 p_xyzMap[line][samp].setX(xyz[0]);
225 p_xyzMap[line][samp].setY(xyz[1]);
226 p_xyzMap[line][samp].setZ(xyz[2]);
235 if (xyz[0] < p_minX) p_minX = xyz[0];
236 if (xyz[0] > p_maxX) p_maxX = xyz[0];
237 if (xyz[1] < p_minY) p_minY = xyz[1];
238 if (xyz[1] > p_maxY) p_maxY = xyz[1];
239 if (xyz[2] < p_minZ) p_minZ = xyz[2];
240 if (xyz[2] > p_maxZ) p_maxZ = xyz[2];
255 if (abs(abs(p_minZ) - radii[2].kilometers()) < 1.0) {
256 p_minZ = radii[2].
kilometers() * (int(abs(p_minZ) / p_minZ));
258 if (abs(abs(p_maxZ) - radii[2].kilometers()) < 1.0) {
259 p_maxZ = radii[2].
kilometers() * (int(abs(p_maxZ) / p_maxZ));
297 if ((imgLine < 0.5) || (imgLine >
p_camera->ParentLines() + 0.5) ||
298 (imgSamp < 0.5) || (imgSamp >
p_camera->ParentSamples() + 0.5)) {
319 SpiceDouble lookC[3];
322 SpiceDouble unitLookC[3];
323 vhat_c(lookC, unitLookC);
324 return p_camera->SetLookDirection(unitLookC);
363 if (p_minX == DBL_MAX || p_maxX == -DBL_MAX ||
364 p_minY == DBL_MAX || p_maxY == -DBL_MAX ||
365 p_minZ == DBL_MAX || p_maxZ == -DBL_MAX)
return false;
368 if (
p_camera->target()->shape()->name() ==
"Plane") {
373 double xCheck = radius * 0.001 * cos(lon.
radians());
374 double yCheck = radius * 0.001 * sin(lon.
radians());
387 if (pB[0] < p_minX || pB[0] > p_maxX ||
388 pB[1] < p_minY || pB[1] > p_maxY ||
389 pB[2] < p_minZ || pB[2] > p_maxZ)
return false;
396 double minDist = DBL_MAX;
401 for (
int line = 0; line <
p_camera->ParentLines(); line++) {
402 for (
int samp = 0; samp <
p_camera->ParentSamples(); samp++) {
404 if (p_xyzMap[line][samp].isNull())
continue;
407 QVector3D deltaXyz = xyz - p_xyzMap[line][samp];
408 if (deltaXyz.length() < minDist) {
409 minDist = deltaXyz.length();
421 if (minDist >= DBL_MAX)
return false;
432 vector<double> knownXyz(4);
435 for (
int line = minLine - 1; line < minLine + 2; line++) {
436 if (line < 0 || line >
p_camera->ParentLines() - 1)
continue;
437 for (
int samp = minSamp - 1; samp < minSamp + 2; samp++) {
439 if (samp < 0 || samp >
p_camera->ParentSamples() - 1)
continue;
440 if (p_xyzMap[line][samp].isNull())
continue;
442 knownXyz[0] = p_xyzMap[line][samp].x();
443 knownXyz[1] = p_xyzMap[line][samp].y();
444 knownXyz[2] = p_xyzMap[line][samp].z();
446 sampXyzLsq.
AddKnown(knownXyz, samp + 1);
447 lineXyzLsq.
AddKnown(knownXyz, line + 1);
451 if (sampXyzLsq.
Knowns() < 4)
return false;
457 knownXyz[0] = xyz.x();
458 knownXyz[1] = xyz.y();
459 knownXyz[2] = xyz.z();
461 double inSamp = sampXyzLsq.
Evaluate(knownXyz);
462 double inLine = lineXyzLsq.
Evaluate(knownXyz);
465 if (inSamp < 0.5 || inSamp >
p_camera->ParentSamples() + 0.5 ||
466 inLine < 0.5 || inLine >
p_camera->ParentLines() + 0.5) {
474 if (!
p_camera->HasSurfaceIntersection())
return false;
520 v[0] = sin(theta) * cos(phi);
522 v[2] = sin(theta) * sin(phi) / -1.;
double radians() const
Convert an angle to a double.
double degrees() const
Get the angle in units of Degrees.
Generic linear equation class.
CameraGroundMap(Camera *parent)
Constructor.
double p_focalPlaneX
Camera's x focal plane coordinate.
double p_focalPlaneY
Camera's y focal plane coordinate.
int ParentLines() const
Returns the number of lines in the parent alphacube.
int ParentSamples() const
Returns the number of samples in the parent alphacube.
Distance measurement, usually in meters.
double kilometers() const
Get the distance in kilometers.
@ 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.
Generic least square fitting class.
int Knowns() const
The number of knowns (or times AddKnown was invoked) linear combination of the variables.
double Evaluate(const std::vector< double > &input)
Invokes the BasisFunction Evaluate method.
int Solve(Isis::LeastSquares::SolveMethod method=SVD)
After all the data has been registered through AddKnown, invoke this method to solve the system of eq...
void AddKnown(const std::vector< double > &input, double expected, double weight=1.0)
Invoke this method for each set of knowns.
This class is designed to encapsulate the concept of a Longitude.
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.
This class defines a body-fixed surface point.
Latitude GetLatitude() const
Return the body-fixed latitude for the surface point.
Longitude GetLongitude() const
Return the body-fixed longitude for the surface point.
double p_visExp
VIS exposure duration, divided by 1000.
virtual ~VimsGroundMap()
Destroys the VimsGroundMap object.
double p_xPixSize
X pixel size.
double p_uz
Distorted focal plane z, in millimeters.
double p_irExp
IR exposure duration, divided by 1000.
QString p_channel
Channel keyword value from the instrument group of the labels.
double p_ux
Distorted focal plane x, in millimeters.
void LookDirection(double v[3])
Determines the look direction in the camera coordinate system.
virtual bool SetGround(const Latitude &lat, const Longitude &lon)
Compute undistorted focal plane coordinate from ground position.
double p_xBore
X boresight.
double p_interlineDelay
InterlineDelayDuration keyword value from the instrument group of the labels, divided by 1000.
int p_swathLength
SwathLength keyword value from the instrument group of the labels.
double p_yBore
Y boresight.
double p_uy
Distorted focal plane y, in millimeters.
VimsGroundMap(Camera *parent, Pvl &lab)
Constructs the VimsGroundMap object.
virtual bool SetFocalPlane(const double ux, const double uy, const double uz)
Compute ground position from focal plane coordinate.
int p_camSampOffset
Sample offset.
int p_swathWidth
SwathWidth keyword value from the instrument group of the labels.
void Init(Pvl &lab)
Initialize vims camera model.
SpiceDouble p_etStart
Start ephemeris time.
int p_camLineOffset
Line offset.
double p_yPixSize
Y pixel size.
This is free and unencumbered software released into the public domain.
const double Null
Value for an Isis Null pixel.
const double HALFPI
The mathematical constant PI/2.
double toDouble(const QString &string)
Global function to convert from a string to a double.
Namespace for the standard library.