From 203584149560a35d571e34e77f4365f7e0e1341b Mon Sep 17 00:00:00 2001 From: Pavel Buchinchik Date: Wed, 27 May 2020 00:48:34 +0300 Subject: [PATCH] server: optimisation for curve integral calculation --- server/api/stats.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server/api/stats.cpp b/server/api/stats.cpp index 92dc3f4..1c65079 100644 --- a/server/api/stats.cpp +++ b/server/api/stats.cpp @@ -325,14 +325,22 @@ double StatsAPI::CalculateSStat(const CoordsOfPoint& point, double value) const auto vec_A = GetNormalizedVector(normed_mean, point_A); auto vec_I = GetNormalizedVector(normed_mean, intersection_point_coords); - double isoline_integral = CalcIntegralOnFullIsoline(isoline_points); + double isoline_integral_on_left_curve = CalcIntegralOnLeftCurveOnIsoline(isoline_points, intersection_point_index, point_index); + double isoline_integral_on_right_curve = CalcIntegralOnRightCurveOnIsoline(isoline_points, intersection_point_index, point_index); + + // double isoline_integral = CalcIntegralOnFullIsoline(isoline_points); + // + // the sum does not exactly coincide with the calculated integral, + // but the difference is in the ~16th digit + double isoline_integral = isoline_integral_on_left_curve + isoline_integral_on_right_curve; + double curve_integral = 0; bool clockwiseDirection = false; if (CheckClockwiseDirection(normed_mean, vec_I, vec_A)) { clockwiseDirection = true; - curve_integral = CalcIntegralOnRightCurveOnIsoline(isoline_points, intersection_point_index, point_index); + curve_integral = isoline_integral_on_right_curve; } else { - curve_integral = CalcIntegralOnLeftCurveOnIsoline(isoline_points, intersection_point_index, point_index); + curve_integral = isoline_integral_on_left_curve; } // return clockwiseDirection too