diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2015-11-12 11:45:58 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2015-11-13 09:25:11 +0000 |
commit | b701bd8cbd46644e28d0dbcae94d5098b72036d8 (patch) | |
tree | c2916d9e1bce6da76a047464d2f48a692dc7bbe9 /basegfx | |
parent | 6b5e4c1f548f459e2d81963efdd4eb661de1fe89 (diff) |
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@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'basegfx')
-rw-r--r-- | basegfx/source/polygon/b2dpolygontools.cxx | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index 2ad4cd05b7f4..6f2542b06838 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; |