[Libreoffice-commits] core.git: basegfx/source
Armin Le Grand
Armin.Le.Grand at cib.de
Fri Nov 13 01:25:35 PST 2015
basegfx/source/polygon/b2dpolygontools.cxx | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
New commits:
commit b701bd8cbd46644e28d0dbcae94d5098b72036d8
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date: Thu Nov 12 11:45:58 2015 +0100
tdf#88352 correct triangulator numerical problem
The basegfx Triangulator is used in slideshow with canvas to triangulate
the mask geometres. This uses tools::isPointInTriangle which uses
basegfx::tools::arePointsOnSameSideOfLine. This uses the cross product
to solve and for tests against zero the fTools::equalZero call. The
triangulator then uses the more precise rtl::math::approxEqual to test
if one of the points of the triangle is equal to the test point.
In rare cases this can lead to a position where a point is seen as inside
the triangle wrongly because it is not detected as equal to one of the
triangle points. To solve, use increased accuracy.
Change-Id: I73e12b711f14d4c48e829d5db1cadefa0917c19b
Reviewed-on: https://gerrit.libreoffice.org/19925
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index 2ad4cd0..6f2542b 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -2186,7 +2186,9 @@ namespace basegfx
const B2DVector aVectorToA(rEnd - rCandidateA);
const double fCrossA(aLineVector.cross(aVectorToA));
- if(fTools::equalZero(fCrossA))
+ // tdf#88352 increase numerical correctness and use rtl::math::approxEqual
+ // instead of fTools::equalZero which compares with a fixed small value
+ if(rtl::math::approxEqual(fCrossA, 0.0))
{
// one point on the line
return bWithLine;
@@ -2195,7 +2197,8 @@ namespace basegfx
const B2DVector aVectorToB(rEnd - rCandidateB);
const double fCrossB(aLineVector.cross(aVectorToB));
- if(fTools::equalZero(fCrossB))
+ // increase numerical correctness
+ if(rtl::math::approxEqual(fCrossB, 0.0))
{
// one point on the line
return bWithLine;
More information about the Libreoffice-commits
mailing list