From fdc0c0cbd12f865c61a1869a6cd034d86f5a74f0 Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Thu, 28 Sep 2023 14:28:17 -0700 Subject: [PATCH] Minor revision to numerical integration code --- src/ifcgeom/mapping/IfcCurveSegment.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ifcgeom/mapping/IfcCurveSegment.cpp b/src/ifcgeom/mapping/IfcCurveSegment.cpp index cd92d229bb..727032895d 100644 --- a/src/ifcgeom/mapping/IfcCurveSegment.cpp +++ b/src/ifcgeom/mapping/IfcCurveSegment.cpp @@ -40,11 +40,11 @@ namespace double integrate(double a, double b, unsigned n, std::function fn) { double area = 0; - double h = (b - a) / (n + 1); - for (auto i = 0; i < n; i++) + double h = (b - a) / n; + for (auto i = 1; i <= n; i++) { - auto x1 = a + h * i; - auto x2 = a + h * (i + 1); + auto x1 = a + h * (i - 1); + auto x2 = a + h * i; auto f1 = fn(x1); auto f2 = fn(x2); area += h * (f1 + f2) / 2.0;