Loading isis/src/apollo/objs/ApolloPanoramicCameraFiducialMap/ApolloPanoramicCameraFiducialMap.cpp +11 −8 Original line number Diff line number Diff line Loading @@ -20,14 +20,17 @@ namespace Isis { p_naifIkCode = naifIkCode; ReadFiducials(fiducials); // Set the x-axis direction. int xdir; if(naifIkCode % 2 == 0) { xdir = -1; } else { xdir = 1; } // // Set the x-axis direction. // int xdir; // if(naifIkCode % 2 == 0) { // xdir = -1; // } // else { // xdir = 1; // } //TODO Why is this commented out? I commented out the code above so we wouldn't get a compiler //warning. 2018-07-14 mshepherd // CreateTrans(xdir); } Loading isis/src/base/objs/SampleScanCameraGroundMap/SampleScanCameraGroundMap.cpp +118 −281 Original line number Diff line number Diff line Loading @@ -49,215 +49,27 @@ using namespace std; using namespace Isis; //bool ptXLessThan(const QList<double> l1, const QList<double> l2); /** * @author 2012-05-09 Orrin Thomas * * @internal */ class SampleOffsetFunctor : public std::unary_function<double, double > { public: SampleOffsetFunctor(Isis::Camera *camera, const Isis::SurfacePoint &surPt) { m_camera = camera; surfacePoint = surPt; } ~SampleOffsetFunctor() {} /** Compute the number of samples between the current sample (i.e., the sample imaged at the et * as set in the camera model) and the sample number where the argument et would hit the focal * plane. * * @param et The et at the new postion * * @return Sample off (see description) */ double operator()(double et) { double lookC[3] = {0.0, 0.0, 0.0}; double ux = 0.0; double uy = 0.0; double dx = 0.0; double dy = 0.0; // Verify the time is with the cache bounds double startTime = m_camera->cacheStartTime().Et(); double endTime = m_camera->cacheEndTime().Et(); if (et < startTime || et > endTime) { IString msg = "Ephemeris time passed to SampleOffsetFunctor is not within the image " "cache bounds"; throw IException(IException::Programmer, msg, _FILEINFO_); } m_camera->Sensor::setTime(et); // Set ground if (!m_camera->Sensor::SetGround(surfacePoint, false)) { IString msg = "Sensor::SetGround failed for surface point in SampleScanCameraGroundMap.cpp" " SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } // Calculate the undistorted focal plane coordinates m_camera->Sensor::LookDirection(lookC); ux = m_camera->FocalLength() * lookC[0] / lookC[2]; uy = m_camera->FocalLength() * lookC[1] / lookC[2]; // Try to use SetUndistortedFocalPlane, if that does not work use the distorted x,y // under the assumption (bad|good) that extrapolating the distortion // is causing the distorted x to be way off the sensor, and thus not very good anyway. if (m_camera->DistortionMap()->SetUndistortedFocalPlane(ux, uy)) { // Get the natural (distorted focal plane coordinates) dx = m_camera->DistortionMap()->FocalPlaneX(); dy = m_camera->DistortionMap()->FocalPlaneY(); } else { dx = ux; dy = uy; } if (!m_camera->FocalPlaneMap()->SetFocalPlane(dx, dy)) { IString msg = "FocalPlaneMap::SetFocalPlane failed for surface point in " "SampleScanCameraGroundMap.cpp SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } // return sample offset in pixels return m_camera->FocalPlaneMap()->CenteredDetectorSample(); } /* double operator()(double et) { double lookC[3] = {0.0, 0.0, 0.0}; double ux = 0.0; double uy = 0.0; double dx = 0.0; double dy = 0.0; // Verify the time is with the cache bounds double startTime = m_camera->cacheStartTime().Et(); double endTime = m_camera->cacheEndTime().Et(); if (et < startTime || et > endTime) { IString msg = "Ephemeris time passed to SampleOffsetFunctor is not within the image " "cache bounds"; throw IException(IException::Programmer, msg, _FILEINFO_); } m_camera->Sensor::setTime(et); // Set ground if (!m_camera->Sensor::SetGround(surfacePoint, false)) { IString msg = "Sensor::SetGround failed for surface point in SampleScanCameraGroundMap.cpp" " SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } // Calculate the undistorted focal plane coordinates m_camera->Sensor::LookDirection(lookC); ux = m_camera->FocalLength() * lookC[0] / lookC[2]; uy = m_camera->FocalLength() * lookC[1] / lookC[2]; // Try to use SetUndistortedFocalPlane, if that does not work use the distorted x,y // under the assumption (bad|good) that extrapolating the distortion // is causing the distorted x to be way off the sensor, and thus not very good anyway. if (m_camera->DistortionMap()->SetUndistortedFocalPlane(ux, uy)) { // Get the natural (distorted focal plane coordinates) dx = m_camera->DistortionMap()->FocalPlaneX(); dy = m_camera->DistortionMap()->FocalPlaneY(); } else { dx = ux; dy = uy; } if (!m_camera->FocalPlaneMap()->SetFocalPlane(dx, dy)) { IString msg = "FocalPlaneMap::SetFocalPlane failed for surface point in " "SampleScanCameraGroundMap.cpp SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } // Return the offset // return (m_camera->FocalPlaneMap()->DetectorSampleOffset() - // m_camera->FocalPlaneMap()->DetectorSample()); return (m_camera->FocalPlaneMap()->DetectorSampleOffset() - m_camera->FocalPlaneMap()->DetectorSample()); } */ private: SurfacePoint surfacePoint; Camera* m_camera; }; /** * @author 2012-05-09 Orrin Thomas * * @internal */ class SensorSurfacePointDistanceFunctor : public std::unary_function<double, double > { public: SensorSurfacePointDistanceFunctor(Isis::Camera *camera, const Isis::SurfacePoint &surPt) { m_camera = camera; surfacePoint = surPt; } ~SensorSurfacePointDistanceFunctor() {} double operator()(double et) { double s[3], p[3]; //verify the time is with the cache bounds double startTime = m_camera->cacheStartTime().Et(); double endTime = m_camera->cacheEndTime().Et(); if (et < startTime || et > endTime) { IString msg = "Ephemeris time passed to SensorSurfacePointDistanceFunctor is not within the image " "cache bounds"; throw IException(IException::Programmer, msg, _FILEINFO_); } m_camera->Sensor::setTime(et); if(!m_camera->Sensor::SetGround(surfacePoint, false)) { IString msg = "Sensor::SetGround failed for surface point in SampleScanCameraGroundMap.cpp" "SensorSurfacePointDistanceFunctor"; } m_camera->instrumentPosition(s); m_camera->Coordinate(p); return sqrt((s[0] - p[0]) * (s[0] - p[0]) + (s[1] - p[1]) * (s[1] - p[1]) + (s[2] - p[2]) * (s[2] - p[2]) ); //distance } private: SurfacePoint surfacePoint; Camera* m_camera; }; namespace Isis { /** Constructor /** * Constructor * * @param cam pointer to camera model */ SampleScanCameraGroundMap::SampleScanCameraGroundMap(Camera *cam) : CameraGroundMap(cam) {} /** Destructor /** * Destructor * */ SampleScanCameraGroundMap::~SampleScanCameraGroundMap() {} /** Compute undistorted focal plane coordinate from ground position /** * Compute undistorted focal plane coordinate from ground position * * @param lat planetocentric latitude in degrees * @param lon planetocentric longitude in degrees Loading @@ -277,7 +89,8 @@ namespace Isis { } /** Compute undistorted focal plane coordinate from ground position /** * Compute undistorted focal plane coordinate from ground position * * @param lat planetocentric latitude in degrees * @param lon planetocentric longitude in degrees Loading @@ -295,7 +108,8 @@ namespace Isis { } /** Compute undistorted focal plane coordinate from ground position /** * Compute undistorted focal plane coordinate from ground position * * @param surfacePoint 3D point on the surface of the planet * Loading Loading @@ -431,109 +245,132 @@ namespace Isis { } /* SampleScanCameraGroundMap::FindFocalPlaneStatus SampleScanCameraGroundMap::FindFocalPlane(const int &approxSample, const SurfacePoint &surfacePoint) { /** * Compute ground position from focal plane coordinate * * This method will compute the ground position given an * undistorted focal plane coordinate. Note that the latitude/longitude * value can be obtained from the camera pointer passed into the constructor. * * @param ux undistorted focal plane x in millimeters * @param uy undistorted focal plane y in millimeters * @param uz undistorted focal plane z in millimeters * * @return @b bool If conversion was successful * * TODO: what is implication of this???????? */ bool SampleScanCameraGroundMap::SetFocalPlane(const double ux, const double uy, const double uz) { return CameraGroundMap::SetFocalPlane(ux, uy, uz); } // check for invalid sample rate (not sure if necessary, Orrin had done this) if (((SampleScanCameraDetectorMap *)p_camera->DetectorMap())->SampleRate() == 0.0) { return Failure; /** * Sample * * @param camera The camera * @param surPoint A pointer to the surface point */ SampleScanCameraGroundMap::SampleOffsetFunctor::SampleOffsetFunctor(Isis::Camera *camera, const Isis::SurfacePoint &surPt) { m_camera = camera; m_surfacePoint = surPt; } SampleOffsetFunctor offsetFunc(p_camera,surfacePoint); double approxTime=0; /** Compute the number of samples between the current sample (i.e., the sample imaged at the et * as set in the camera model) and the sample number where the argument et would hit the focal * plane. * * @param et The et at the new postion * * @return Sample off (see description) */ double SampleScanCameraGroundMap::SampleOffsetFunctor::operator()(double et) { double lookC[3] = {0.0, 0.0, 0.0}; double ux = 0.0; double uy = 0.0; double dx = 0.0; double dy = 0.0; // mid-sample and mid-line are first approximation double midSample = p_camera->ParentSamples()/2.0; double midLine = p_camera->ParentLines()/2.0; p_camera->DetectorMap()->SetParent(midSample, midLine); approxTime = p_camera->time().Et(); double approxOffset = offsetFunc(approxTime); bool converged = false; do { p_camera->Sensor::setTime(approxTime); // ensure surfacePoint isn't behind the planet if (!p_camera->Sensor::SetGround(surfacePoint, false)) { return Failure; // Verify the time is with the cache bounds double startTime = m_camera->cacheStartTime().Et(); double endTime = m_camera->cacheEndTime().Et(); if (et < startTime || et > endTime) { IString msg = "Ephemeris time passed to SampleOffsetFunctor is not within the image " "cache bounds"; throw IException(IException::Programmer, msg, _FILEINFO_); } p_camera->Sensor::LookDirection(lookC); ux = p_camera->FocalLength() * lookC[0] / lookC[2]; uy = p_camera->FocalLength() * lookC[1] / lookC[2]; m_camera->Sensor::setTime(et); if (fabs(uy) < 1.0e-4) { // we have converged converged = true; break; // Set ground if (!m_camera->Sensor::SetGround(m_surfacePoint, false)) { IString msg = "Sensor::SetGround failed for surface point in SampleScanCameraGroundMap.cpp" " SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } // if not converged, add uy/pixelpitch to starting sample and try again midSample += uy/0.005; double parentSample = p_camera->DetectorMap()->ParentSample(); double parentLine = p_camera->DetectorMap()->ParentLine(); p_camera->DetectorMap()->SetParent(midSample, midLine); approxTime = p_camera->time().Et(); } while (converged == false); // Calculate the undistorted focal plane coordinates if (converged) { p_camera->Sensor::setTime(approxTime); m_camera->Sensor::LookDirection(lookC); ux = m_camera->FocalLength() * lookC[0] / lookC[2]; uy = m_camera->FocalLength() * lookC[1] / lookC[2]; //check to make sure the point isn't behind the planet if (!p_camera->Sensor::SetGround(surfacePoint, true)) { return Failure; // Try to use SetUndistortedFocalPlane, if that does not work use the distorted x,y // under the assumption (bad|good) that extrapolating the distortion // is causing the distorted x to be way off the sensor, and thus not very good anyway. if (m_camera->DistortionMap()->SetUndistortedFocalPlane(ux, uy)) { // Get the natural (distorted focal plane coordinates) dx = m_camera->DistortionMap()->FocalPlaneX(); dy = m_camera->DistortionMap()->FocalPlaneY(); } else { dx = ux; dy = uy; } p_camera->Sensor::LookDirection(lookC); ux = p_camera->FocalLength() * lookC[0] / lookC[2]; uy = p_camera->FocalLength() * lookC[1] / lookC[2]; if (!p_camera->FocalPlaneMap()->SetFocalPlane(ux, uy)) { if (!m_camera->FocalPlaneMap()->SetFocalPlane(dx, dy)) { IString msg = "FocalPlaneMap::SetFocalPlane failed for surface point in " "SampleScanCameraGroundMap.cpp SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } p_focalPlaneX = ux; p_focalPlaneY = uy; return Success; // return sample offset in pixels return m_camera->FocalPlaneMap()->CenteredDetectorSample(); } return Failure; } */ /** * Compute ground position from focal plane coordinate * * This method will compute the ground position given an * undistorted focal plane coordinate. Note that the latitude/longitude * value can be obtained from the camera pointer passed into the constructor. * * @param ux undistorted focal plane x in millimeters * @param uy undistorted focal plane y in millimeters * @param uz undistorted focal plane z in millimeters * * @return @b bool If conversion was successful * * TODO: what is implication of this???????? */ bool SampleScanCameraGroundMap::SetFocalPlane(const double ux, const double uy, const double uz) { return CameraGroundMap::SetFocalPlane(ux, uy, uz); SampleScanCameraGroundMap::SensorSurfacePointDistanceFunctor::SensorSurfacePointDistanceFunctor (Isis::Camera *camera, const Isis::SurfacePoint &surPt) { m_camera = camera; m_surfacePoint = surPt; } } double SampleScanCameraGroundMap::SensorSurfacePointDistanceFunctor::operator()(double et) { double s[3], p[3]; //verify the time is with the cache bounds double startTime = m_camera->cacheStartTime().Et(); double endTime = m_camera->cacheEndTime().Et(); if (et < startTime || et > endTime) { IString msg = "Ephemeris time passed to SensorSurfacePointDistanceFunctor is not within the " "image cache bounds"; throw IException(IException::Programmer, msg, _FILEINFO_); } m_camera->Sensor::setTime(et); if(!m_camera->Sensor::SetGround(m_surfacePoint, false)) { IString msg = "Sensor::SetGround failed for surface point in SampleScanCameraGroundMap.cpp" "SensorSurfacePointDistanceFunctor"; } m_camera->instrumentPosition(s); m_camera->Coordinate(p); return sqrt((s[0] - p[0]) * (s[0] - p[0]) + (s[1] - p[1]) * (s[1] - p[1]) + (s[2] - p[2]) * (s[2] - p[2]) ); //distance } } //bool ptXLessThan(const QList<double> l1, const QList<double> l2) { // return l1[0] < l2[0]; //} isis/src/base/objs/SampleScanCameraGroundMap/SampleScanCameraGroundMap.h +41 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ namespace Isis { * @internal * * @history 2012-09-12 Ken Edmundson - Original version * @history 2018-07-14 Makayla Shepherd - Updated documentation * */ class SampleScanCameraGroundMap : public CameraGroundMap { Loading Loading @@ -71,6 +72,45 @@ namespace Isis { const SurfacePoint &surfacePoint); double FindSpacecraftDistance(int sample, const SurfacePoint &surfacePoint); private: /** * @author 2012-05-09 Orrin Thomas * * @internal */ class SampleOffsetFunctor : public std::unary_function<double, double > { public: SampleOffsetFunctor(Isis::Camera *camera, const Isis::SurfacePoint &surPt); ~SampleOffsetFunctor(); double operator()(double et); private: SurfacePoint m_surfacePoint; Camera *m_camera; }; /** * @author 2012-05-09 Orrin Thomas * * @internal */ class SensorSurfacePointDistanceFunctor : public std::unary_function<double, double > { public: SensorSurfacePointDistanceFunctor(Isis::Camera *camera, const Isis::SurfacePoint &surPt); ~SensorSurfacePointDistanceFunctor(); double operator()(double et); private: SurfacePoint m_surfacePoint; Camera* m_camera; }; }; }; #endif Loading
isis/src/apollo/objs/ApolloPanoramicCameraFiducialMap/ApolloPanoramicCameraFiducialMap.cpp +11 −8 Original line number Diff line number Diff line Loading @@ -20,14 +20,17 @@ namespace Isis { p_naifIkCode = naifIkCode; ReadFiducials(fiducials); // Set the x-axis direction. int xdir; if(naifIkCode % 2 == 0) { xdir = -1; } else { xdir = 1; } // // Set the x-axis direction. // int xdir; // if(naifIkCode % 2 == 0) { // xdir = -1; // } // else { // xdir = 1; // } //TODO Why is this commented out? I commented out the code above so we wouldn't get a compiler //warning. 2018-07-14 mshepherd // CreateTrans(xdir); } Loading
isis/src/base/objs/SampleScanCameraGroundMap/SampleScanCameraGroundMap.cpp +118 −281 Original line number Diff line number Diff line Loading @@ -49,215 +49,27 @@ using namespace std; using namespace Isis; //bool ptXLessThan(const QList<double> l1, const QList<double> l2); /** * @author 2012-05-09 Orrin Thomas * * @internal */ class SampleOffsetFunctor : public std::unary_function<double, double > { public: SampleOffsetFunctor(Isis::Camera *camera, const Isis::SurfacePoint &surPt) { m_camera = camera; surfacePoint = surPt; } ~SampleOffsetFunctor() {} /** Compute the number of samples between the current sample (i.e., the sample imaged at the et * as set in the camera model) and the sample number where the argument et would hit the focal * plane. * * @param et The et at the new postion * * @return Sample off (see description) */ double operator()(double et) { double lookC[3] = {0.0, 0.0, 0.0}; double ux = 0.0; double uy = 0.0; double dx = 0.0; double dy = 0.0; // Verify the time is with the cache bounds double startTime = m_camera->cacheStartTime().Et(); double endTime = m_camera->cacheEndTime().Et(); if (et < startTime || et > endTime) { IString msg = "Ephemeris time passed to SampleOffsetFunctor is not within the image " "cache bounds"; throw IException(IException::Programmer, msg, _FILEINFO_); } m_camera->Sensor::setTime(et); // Set ground if (!m_camera->Sensor::SetGround(surfacePoint, false)) { IString msg = "Sensor::SetGround failed for surface point in SampleScanCameraGroundMap.cpp" " SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } // Calculate the undistorted focal plane coordinates m_camera->Sensor::LookDirection(lookC); ux = m_camera->FocalLength() * lookC[0] / lookC[2]; uy = m_camera->FocalLength() * lookC[1] / lookC[2]; // Try to use SetUndistortedFocalPlane, if that does not work use the distorted x,y // under the assumption (bad|good) that extrapolating the distortion // is causing the distorted x to be way off the sensor, and thus not very good anyway. if (m_camera->DistortionMap()->SetUndistortedFocalPlane(ux, uy)) { // Get the natural (distorted focal plane coordinates) dx = m_camera->DistortionMap()->FocalPlaneX(); dy = m_camera->DistortionMap()->FocalPlaneY(); } else { dx = ux; dy = uy; } if (!m_camera->FocalPlaneMap()->SetFocalPlane(dx, dy)) { IString msg = "FocalPlaneMap::SetFocalPlane failed for surface point in " "SampleScanCameraGroundMap.cpp SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } // return sample offset in pixels return m_camera->FocalPlaneMap()->CenteredDetectorSample(); } /* double operator()(double et) { double lookC[3] = {0.0, 0.0, 0.0}; double ux = 0.0; double uy = 0.0; double dx = 0.0; double dy = 0.0; // Verify the time is with the cache bounds double startTime = m_camera->cacheStartTime().Et(); double endTime = m_camera->cacheEndTime().Et(); if (et < startTime || et > endTime) { IString msg = "Ephemeris time passed to SampleOffsetFunctor is not within the image " "cache bounds"; throw IException(IException::Programmer, msg, _FILEINFO_); } m_camera->Sensor::setTime(et); // Set ground if (!m_camera->Sensor::SetGround(surfacePoint, false)) { IString msg = "Sensor::SetGround failed for surface point in SampleScanCameraGroundMap.cpp" " SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } // Calculate the undistorted focal plane coordinates m_camera->Sensor::LookDirection(lookC); ux = m_camera->FocalLength() * lookC[0] / lookC[2]; uy = m_camera->FocalLength() * lookC[1] / lookC[2]; // Try to use SetUndistortedFocalPlane, if that does not work use the distorted x,y // under the assumption (bad|good) that extrapolating the distortion // is causing the distorted x to be way off the sensor, and thus not very good anyway. if (m_camera->DistortionMap()->SetUndistortedFocalPlane(ux, uy)) { // Get the natural (distorted focal plane coordinates) dx = m_camera->DistortionMap()->FocalPlaneX(); dy = m_camera->DistortionMap()->FocalPlaneY(); } else { dx = ux; dy = uy; } if (!m_camera->FocalPlaneMap()->SetFocalPlane(dx, dy)) { IString msg = "FocalPlaneMap::SetFocalPlane failed for surface point in " "SampleScanCameraGroundMap.cpp SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } // Return the offset // return (m_camera->FocalPlaneMap()->DetectorSampleOffset() - // m_camera->FocalPlaneMap()->DetectorSample()); return (m_camera->FocalPlaneMap()->DetectorSampleOffset() - m_camera->FocalPlaneMap()->DetectorSample()); } */ private: SurfacePoint surfacePoint; Camera* m_camera; }; /** * @author 2012-05-09 Orrin Thomas * * @internal */ class SensorSurfacePointDistanceFunctor : public std::unary_function<double, double > { public: SensorSurfacePointDistanceFunctor(Isis::Camera *camera, const Isis::SurfacePoint &surPt) { m_camera = camera; surfacePoint = surPt; } ~SensorSurfacePointDistanceFunctor() {} double operator()(double et) { double s[3], p[3]; //verify the time is with the cache bounds double startTime = m_camera->cacheStartTime().Et(); double endTime = m_camera->cacheEndTime().Et(); if (et < startTime || et > endTime) { IString msg = "Ephemeris time passed to SensorSurfacePointDistanceFunctor is not within the image " "cache bounds"; throw IException(IException::Programmer, msg, _FILEINFO_); } m_camera->Sensor::setTime(et); if(!m_camera->Sensor::SetGround(surfacePoint, false)) { IString msg = "Sensor::SetGround failed for surface point in SampleScanCameraGroundMap.cpp" "SensorSurfacePointDistanceFunctor"; } m_camera->instrumentPosition(s); m_camera->Coordinate(p); return sqrt((s[0] - p[0]) * (s[0] - p[0]) + (s[1] - p[1]) * (s[1] - p[1]) + (s[2] - p[2]) * (s[2] - p[2]) ); //distance } private: SurfacePoint surfacePoint; Camera* m_camera; }; namespace Isis { /** Constructor /** * Constructor * * @param cam pointer to camera model */ SampleScanCameraGroundMap::SampleScanCameraGroundMap(Camera *cam) : CameraGroundMap(cam) {} /** Destructor /** * Destructor * */ SampleScanCameraGroundMap::~SampleScanCameraGroundMap() {} /** Compute undistorted focal plane coordinate from ground position /** * Compute undistorted focal plane coordinate from ground position * * @param lat planetocentric latitude in degrees * @param lon planetocentric longitude in degrees Loading @@ -277,7 +89,8 @@ namespace Isis { } /** Compute undistorted focal plane coordinate from ground position /** * Compute undistorted focal plane coordinate from ground position * * @param lat planetocentric latitude in degrees * @param lon planetocentric longitude in degrees Loading @@ -295,7 +108,8 @@ namespace Isis { } /** Compute undistorted focal plane coordinate from ground position /** * Compute undistorted focal plane coordinate from ground position * * @param surfacePoint 3D point on the surface of the planet * Loading Loading @@ -431,109 +245,132 @@ namespace Isis { } /* SampleScanCameraGroundMap::FindFocalPlaneStatus SampleScanCameraGroundMap::FindFocalPlane(const int &approxSample, const SurfacePoint &surfacePoint) { /** * Compute ground position from focal plane coordinate * * This method will compute the ground position given an * undistorted focal plane coordinate. Note that the latitude/longitude * value can be obtained from the camera pointer passed into the constructor. * * @param ux undistorted focal plane x in millimeters * @param uy undistorted focal plane y in millimeters * @param uz undistorted focal plane z in millimeters * * @return @b bool If conversion was successful * * TODO: what is implication of this???????? */ bool SampleScanCameraGroundMap::SetFocalPlane(const double ux, const double uy, const double uz) { return CameraGroundMap::SetFocalPlane(ux, uy, uz); } // check for invalid sample rate (not sure if necessary, Orrin had done this) if (((SampleScanCameraDetectorMap *)p_camera->DetectorMap())->SampleRate() == 0.0) { return Failure; /** * Sample * * @param camera The camera * @param surPoint A pointer to the surface point */ SampleScanCameraGroundMap::SampleOffsetFunctor::SampleOffsetFunctor(Isis::Camera *camera, const Isis::SurfacePoint &surPt) { m_camera = camera; m_surfacePoint = surPt; } SampleOffsetFunctor offsetFunc(p_camera,surfacePoint); double approxTime=0; /** Compute the number of samples between the current sample (i.e., the sample imaged at the et * as set in the camera model) and the sample number where the argument et would hit the focal * plane. * * @param et The et at the new postion * * @return Sample off (see description) */ double SampleScanCameraGroundMap::SampleOffsetFunctor::operator()(double et) { double lookC[3] = {0.0, 0.0, 0.0}; double ux = 0.0; double uy = 0.0; double dx = 0.0; double dy = 0.0; // mid-sample and mid-line are first approximation double midSample = p_camera->ParentSamples()/2.0; double midLine = p_camera->ParentLines()/2.0; p_camera->DetectorMap()->SetParent(midSample, midLine); approxTime = p_camera->time().Et(); double approxOffset = offsetFunc(approxTime); bool converged = false; do { p_camera->Sensor::setTime(approxTime); // ensure surfacePoint isn't behind the planet if (!p_camera->Sensor::SetGround(surfacePoint, false)) { return Failure; // Verify the time is with the cache bounds double startTime = m_camera->cacheStartTime().Et(); double endTime = m_camera->cacheEndTime().Et(); if (et < startTime || et > endTime) { IString msg = "Ephemeris time passed to SampleOffsetFunctor is not within the image " "cache bounds"; throw IException(IException::Programmer, msg, _FILEINFO_); } p_camera->Sensor::LookDirection(lookC); ux = p_camera->FocalLength() * lookC[0] / lookC[2]; uy = p_camera->FocalLength() * lookC[1] / lookC[2]; m_camera->Sensor::setTime(et); if (fabs(uy) < 1.0e-4) { // we have converged converged = true; break; // Set ground if (!m_camera->Sensor::SetGround(m_surfacePoint, false)) { IString msg = "Sensor::SetGround failed for surface point in SampleScanCameraGroundMap.cpp" " SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } // if not converged, add uy/pixelpitch to starting sample and try again midSample += uy/0.005; double parentSample = p_camera->DetectorMap()->ParentSample(); double parentLine = p_camera->DetectorMap()->ParentLine(); p_camera->DetectorMap()->SetParent(midSample, midLine); approxTime = p_camera->time().Et(); } while (converged == false); // Calculate the undistorted focal plane coordinates if (converged) { p_camera->Sensor::setTime(approxTime); m_camera->Sensor::LookDirection(lookC); ux = m_camera->FocalLength() * lookC[0] / lookC[2]; uy = m_camera->FocalLength() * lookC[1] / lookC[2]; //check to make sure the point isn't behind the planet if (!p_camera->Sensor::SetGround(surfacePoint, true)) { return Failure; // Try to use SetUndistortedFocalPlane, if that does not work use the distorted x,y // under the assumption (bad|good) that extrapolating the distortion // is causing the distorted x to be way off the sensor, and thus not very good anyway. if (m_camera->DistortionMap()->SetUndistortedFocalPlane(ux, uy)) { // Get the natural (distorted focal plane coordinates) dx = m_camera->DistortionMap()->FocalPlaneX(); dy = m_camera->DistortionMap()->FocalPlaneY(); } else { dx = ux; dy = uy; } p_camera->Sensor::LookDirection(lookC); ux = p_camera->FocalLength() * lookC[0] / lookC[2]; uy = p_camera->FocalLength() * lookC[1] / lookC[2]; if (!p_camera->FocalPlaneMap()->SetFocalPlane(ux, uy)) { if (!m_camera->FocalPlaneMap()->SetFocalPlane(dx, dy)) { IString msg = "FocalPlaneMap::SetFocalPlane failed for surface point in " "SampleScanCameraGroundMap.cpp SampleOffsetFunctor"; throw IException(IException::Programmer, msg, _FILEINFO_); } p_focalPlaneX = ux; p_focalPlaneY = uy; return Success; // return sample offset in pixels return m_camera->FocalPlaneMap()->CenteredDetectorSample(); } return Failure; } */ /** * Compute ground position from focal plane coordinate * * This method will compute the ground position given an * undistorted focal plane coordinate. Note that the latitude/longitude * value can be obtained from the camera pointer passed into the constructor. * * @param ux undistorted focal plane x in millimeters * @param uy undistorted focal plane y in millimeters * @param uz undistorted focal plane z in millimeters * * @return @b bool If conversion was successful * * TODO: what is implication of this???????? */ bool SampleScanCameraGroundMap::SetFocalPlane(const double ux, const double uy, const double uz) { return CameraGroundMap::SetFocalPlane(ux, uy, uz); SampleScanCameraGroundMap::SensorSurfacePointDistanceFunctor::SensorSurfacePointDistanceFunctor (Isis::Camera *camera, const Isis::SurfacePoint &surPt) { m_camera = camera; m_surfacePoint = surPt; } } double SampleScanCameraGroundMap::SensorSurfacePointDistanceFunctor::operator()(double et) { double s[3], p[3]; //verify the time is with the cache bounds double startTime = m_camera->cacheStartTime().Et(); double endTime = m_camera->cacheEndTime().Et(); if (et < startTime || et > endTime) { IString msg = "Ephemeris time passed to SensorSurfacePointDistanceFunctor is not within the " "image cache bounds"; throw IException(IException::Programmer, msg, _FILEINFO_); } m_camera->Sensor::setTime(et); if(!m_camera->Sensor::SetGround(m_surfacePoint, false)) { IString msg = "Sensor::SetGround failed for surface point in SampleScanCameraGroundMap.cpp" "SensorSurfacePointDistanceFunctor"; } m_camera->instrumentPosition(s); m_camera->Coordinate(p); return sqrt((s[0] - p[0]) * (s[0] - p[0]) + (s[1] - p[1]) * (s[1] - p[1]) + (s[2] - p[2]) * (s[2] - p[2]) ); //distance } } //bool ptXLessThan(const QList<double> l1, const QList<double> l2) { // return l1[0] < l2[0]; //}
isis/src/base/objs/SampleScanCameraGroundMap/SampleScanCameraGroundMap.h +41 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ namespace Isis { * @internal * * @history 2012-09-12 Ken Edmundson - Original version * @history 2018-07-14 Makayla Shepherd - Updated documentation * */ class SampleScanCameraGroundMap : public CameraGroundMap { Loading Loading @@ -71,6 +72,45 @@ namespace Isis { const SurfacePoint &surfacePoint); double FindSpacecraftDistance(int sample, const SurfacePoint &surfacePoint); private: /** * @author 2012-05-09 Orrin Thomas * * @internal */ class SampleOffsetFunctor : public std::unary_function<double, double > { public: SampleOffsetFunctor(Isis::Camera *camera, const Isis::SurfacePoint &surPt); ~SampleOffsetFunctor(); double operator()(double et); private: SurfacePoint m_surfacePoint; Camera *m_camera; }; /** * @author 2012-05-09 Orrin Thomas * * @internal */ class SensorSurfacePointDistanceFunctor : public std::unary_function<double, double > { public: SensorSurfacePointDistanceFunctor(Isis::Camera *camera, const Isis::SurfacePoint &surPt); ~SensorSurfacePointDistanceFunctor(); double operator()(double et); private: SurfacePoint m_surfacePoint; Camera* m_camera; }; }; }; #endif