Skip to content

Commit

Permalink
server: optimisation for curve integral calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bychin committed May 26, 2020
1 parent 98d946f commit 2035841
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions server/api/stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2035841

Please sign in to comment.