diff --git a/glasscore/traveltime/include/TravelTime.h b/glasscore/traveltime/include/TravelTime.h index 656e62de..966d2fc1 100644 --- a/glasscore/traveltime/include/TravelTime.h +++ b/glasscore/traveltime/include/TravelTime.h @@ -155,20 +155,21 @@ class CTravelTime { * * Compute a bilinear interpolation from the provided values * - * \param v11 - A double containing the interpolation value for (x1, y1) - * \param v12 - A double containing the interpolation value for (x1, y2) - * \param v21 - A double containing the interpolation value for (x2, y1) - * \param v22 - A double containing the interpolation value for (x2, y2) + * \param q_x1y1 - A double containing the interpolation value for (x1, y1) + * \param q_x1y2 - A double containing the interpolation value for (x1, y2) + * \param q_x2y1 - A double containing the interpolation value for (x2, y1) + * \param q_x2y2 - A double containing the interpolation value for (x2, y2) * \param x1 - A double containing first x interpolation coordinate - * \param x2 - A double containing second x interpolation coordinate * \param y1 - A double containing first y interpolation coordinate + * \param x2 - A double containing second x interpolation coordinate * \param y2 - A double containing second y interpolation coordinate * \param x - A double containing the given x coordinate * \param y - A double containing the given y coordinate * \return Returns a double containing the resulting bilinear interpolation */ - double bilinearInterpolation(double v11, double v12, double v21, - double v22, double x1, double x2, double y1, double y2, double x, double y); + double bilinearInterpolation(double q_x1y1, double q_x1y2, double q_x2y1, + double q_x2y2, double x1, double y1, double x2, double y2, double x, + double y); /** * \brief Compute interpolation grid distance index diff --git a/glasscore/traveltime/src/TravelTime.cpp b/glasscore/traveltime/src/TravelTime.cpp index 1715a241..4c19b967 100644 --- a/glasscore/traveltime/src/TravelTime.cpp +++ b/glasscore/traveltime/src/TravelTime.cpp @@ -340,10 +340,10 @@ double CTravelTime::T(double delta) { // input distance/depth double outTravelTime = bilinearInterpolation( travelTime11, travelTime12, travelTime21, travelTime22, - distance1, distance2, depth1, depth2, + distance1, depth1, distance2, depth2, inDistance, inDepth); - // check final trave ltime + // check final travel time if (outTravelTime < 0) { // no traveltime return (k_dTravelTimeInvalid); @@ -378,7 +378,7 @@ int CTravelTime::getIndexFromDistance(double distance) { } } -// ------------------------------------------------------getDepthFromIndex +// ------------------------------------------------------getDistanceFromIndex double CTravelTime::getDistanceFromIndex(int index) { if (m_dDistanceStep < 0) { return (0); @@ -433,9 +433,10 @@ double CTravelTime::getDepthFromIndex(int index) { } // -------------------------------------------------------bilinearInterpolation -double CTravelTime::bilinearInterpolation(double v11, double v12, double v21, - double v22, double x1, double x2, double y1, double y2, double x, double y) { - // check values +double CTravelTime::bilinearInterpolation(double q_x1y1, double q_x1y2, + double q_x2y1, double q_x2y2, double x1, double y1, double x2, double y2, + double x, double y) { + // check values to avoid div by 0 if ((x1 == x2) || (y1 == y2)) { return(-1.0); } @@ -448,10 +449,10 @@ double CTravelTime::bilinearInterpolation(double v11, double v12, double v21, double xx1 = x - x1; return 1.0 / (x2x1 * y2y1) * ( - v11 * x2x * y2y + - v21 * xx1 * y2y + - v12 * x2x * yy1 + - v22 * xx1 * yy1); + q_x1y1 * x2x * y2y + + q_x2y1 * xx1 * y2y + + q_x1y2 * x2x * yy1 + + q_x2y2 * xx1 * yy1); } // ---------------------------------------------------------T