Commit 9870089f authored by Kim Oyama's avatar Kim Oyama
Browse files

In SunShadowTool, corrected the equation, in the recalculateShadowHeight()...

In SunShadowTool, corrected the equation, in the recalculateShadowHeight() method, that finds the height of the object casting the shadow. It now uses the tangent of the angle multiplied by the length of the shadow instead of the sine of the angle. Fixes #1933.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@5710 41f8697f-d340-4b68-9986-7bafba869bb8
parent 90485ef4
Loading
Loading
Loading
Loading
+33 −41
Changes for isis/src/qisis/objs/SunShadowTool/SunShadowTool.cpp: 33 added lines, 41 removed lines.
Original line number Diff line number Diff line
@@ -451,36 +451,34 @@ namespace Isis {
        m_path = FileName(cubeViewport()->cube()->fileName()).path();
        m_fileName = FileName(cubeViewport()->cube()->fileName()).name();

        //
        // \  |  /
        //  \ | /
        //    _
        //-- / \ --    THE SUN
        //-- \_/ --
        //  / | \  -
        // /  |  \   -      <--- vector from the sun that intersects P1 and P2
        //             -
        //     _         -_
        //     ^         /^\-     P2
        //     |        / | \  -   |
        //   H |       /  |  \   - v
        //    _v______/  P1   \__T_-_________
        //                      ^
        //                    Shadow
        //
        //   T: Angle from the horizon to the sun
        //   H: Difference in planetary radius between P1 and P2
        //   L : length(Shadow)
        //   H = L * sin(T)
        //
        // We do not want the local incidence angle for T.
        //
        // Equation to variable mapping:
        //   T: theta
        //   H: m_shadowHeight
        //   L: m_shadowLength
        //   P1: m_startSurfacePoint
        //   P2: m_endSurfacePoint
        /*     |
         *   \ _ /
         * -= (_) =-    THE SUN
         *   /   \ -
         *     |     -      <--- vector from the sun that intersects P1 and P2
         *              -
         *                -_         |
         *                /^\-       | 
         *               / | \  -    |
         *              / H|  \   -  |
         *     ________/   |   \__T_-|_________
         *                 P1     ^  P2
         *                     Shadow
         *
         *  T: Angle from the horizon to the sun
         *  H: Difference in planetary radius between P1 and P2
         *  L : length(Shadow)
         *  H = L * tan(T)
         *
         * We do not want the local incidence angle for T.
         *
         * Equation to variable mapping:
         *  T: theta
         *  H: m_shadowHeight
         *  L: m_shadowLength
         *  P1: m_startSurfacePoint
         *  P2: m_endSurfacePoint
         */
        
        bool success = true;
        Camera *cam = cubeViewport()->cube()->camera();
@@ -525,24 +523,18 @@ namespace Isis {
          *m_incidenceAngle = Angle(cam->IncidenceAngle(), Angle::Degrees);
          Angle theta = Angle(90.0, Angle::Degrees) - *m_incidenceAngle;

          Displacement deltaX = m_startSurfacePoint->GetX() -
                                m_endSurfacePoint->GetX();
          Displacement deltaX = m_startSurfacePoint->GetX() - m_endSurfacePoint->GetX();

          Displacement deltaY = m_startSurfacePoint->GetY() -
                                m_endSurfacePoint->GetY();
          Displacement deltaY = m_startSurfacePoint->GetY() - m_endSurfacePoint->GetY();

          Displacement deltaZ = m_startSurfacePoint->GetZ() -
                                m_endSurfacePoint->GetZ();
          Displacement deltaZ = m_startSurfacePoint->GetZ() - m_endSurfacePoint->GetZ();

          *m_shadowLength = Distance(
            sqrt(
              deltaX.meters() * deltaX.meters() +
          *m_shadowLength = Distance(sqrt( deltaX.meters() * deltaX.meters() +
                                           deltaY.meters() * deltaY.meters() +
                                           deltaZ.meters() * deltaZ.meters() ),
                                     Distance::Meters);

          *m_shadowHeight = Distance(
              m_shadowLength->meters() * sin(theta.radians()),
          *m_shadowHeight = Distance(m_shadowLength->meters() * tan( theta.radians() ),
                                     Distance::Meters);
        }
      }
+5 −1
Changes for isis/src/qisis/objs/SunShadowTool/SunShadowTool.h: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -28,8 +28,12 @@ namespace Isis {
  * @author 2012-03-12 Steven Lambright
  *
  * @internal
  *  @history 2012-07-06 Debbie A. Cook, Updated Spice members to be more compliant with Isis 
  *  @history 2012-07-06 Debbie A. Cook - Updated Spice members to be more compliant with Isis
  *                          coding standards. References #972.
  *  @history 2014-01-16 Kimberly Oyama - Corrected the equation, in the recalculateShadowHeight()
  *                          method, that finds the height of the object casting the shadow. It now
  *                          uses the tangent of the angle multiplied by the length of the shadow
  *                          instead of the sine of the angle. Fixes #1933.
  */
  class SunShadowTool : public Tool {
      Q_OBJECT