-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[intersection] \pgfintersectionofpaths
yields an error when the lines are almost parallel
#369
Comments
Migrated from SourceForge
Diff:
-The error produced is Prior to calling
|
Has any progress been made on this issue? |
There is a new situation triggering the bug, see this answer on TeX.SE. I believe the bug is triggered due to the increased accuracy of |
Thanks Sašo for investigating. Can you suggest a fix? |
Confirmed, there are still some false positives. The lines below intersect at (7533.0596514639865, -18161.393051431558), which is out of TeX's range, so it should be reported as non-intersecting.
|
I looked at the code of I'll investigate the new situation further to see if I was correct in thinking that the |
In fact, I have a suggestion for a fix! I have identified the points in I'm attaching the patch, but I believe it shouldn't be used as it is, as don't really know how to use FPU, so the code is clumsy. |
Thank you for the patch, but we can't use the FPU here, because it comes with a critical performance hit. |
Fixes the situation described in issue pgf-tikz#369 (discussion after November 2019). A family of `\pgfutil@ifsafeto...` macros is defined, testing whether an operation can be safely applied to the given dimensions. * `\pgfutil@ifsafetoadd` tests addition, * `\pgfutil@ifsafetosubtract` tests subtraction, * `\pgfutil@ifsafetomultiply` tests multiplication, and * `\pgfutil@ifsafetomultiplybynumber` tests multiplication of a "floating" number (i.e. a unitless dimension) and a dimension; the special case is needed as the number can exceed \maxdimen (given in pts). Usage: `\pgfutil@ifsafeto...{first dimen}{second dimen}{true code}{false code}` `true code` must contain the code which performs the actual operation. Before `false code` is executed, `\ifpgf@dimen@overflow` is globally set to true, so that the caller can check for overflows. As a consequence of using `\pgfutil@ifsafeto...`, `\pgf@iflinesintersect@` now gracefully handles large coordinates, all the way up to `\maxdimen`. However, when a segment is longer than `\maxdimen`, the macro still yields a false negative. The execution time increases by 1% - 1.5%.
You're right, of course. The FPU-based patch increased the execution time by 4%, and I have noticed that it didn't address even half of the problematic points. The new fix incurs about 1.5% overhead. I've tested it extensively: the errors are gone, and the results match what Python computes (within the bounds of of TeX's precision) -- one can even use dimensions all the way up to The solution is simply to divide the given dimensions by 128 (128*128=\maxdimen) for multiplication tests, and by 2 for addition tests. |
Incidentally, there's a |
Migrated from SourceForge
Author: avani42
Timestamp: 2015-10-22 18:47:05.333000
\pgfintersectionofpaths
yields an error when the lines it is trying to intersect are almost parallel. This bug was discovered by users of packageforest
and attributed to PGF, see TeX.SE question http://tex.stackexchange.com/questions/204094/sn-edges-and-nice-empty-nodes-styles-in-forest-lead-to-dividing-by-zero-whats.This is an example of code that produces the error.
The error produced is
The "call stack" is (
\pgfintersectionofpaths
,\pgfpointintersectionoflines
,\pgftransforminvert
): so the error occurs during\pgftransforminvert
, just as the documentation of this macro claims would happen if the matrix its trying to invert is near-singular.Prior to calling
\pgfpointintersectionoflines
to actually compute the intesection of lines,\pgf@intersectionoflines
(indirectly called by\pgfintersectionofpaths
) tries to figure out whether the lines intersect at all, and the problem seems to be in this part of the code, namely macro\pgf@iflinesintersect
, which apparently reports the lines to intersect, although computing the intersection later yields an error.The expected behaviour would be for
\pgfpointintersectionoflines
and\pgfiflinesintersect
to be consistent.The text was updated successfully, but these errors were encountered: