loopspace / spath3

TikZ/PGF package for manipulating soft paths, includes the knots and calligraphy TikZ libraries.
16 stars 2 forks source link

Dimension too large error #27

Closed crimestop closed 9 months ago

crimestop commented 10 months ago

I'm current using knots package v2.4 on texlive 2023. We compiling the following code

        \begin{tikzpicture}
        \begin{knot}[
            %draft mode=crossings,
            clip width=3,
        ]
            \strand (0,0)  --(2,2);
            \strand (0.5,0)  --(2.5,2);
        \end{knot}
    \end{tikzpicture}

the compiler(pdflatex) reports a "Dimension too large." error. However there's no error if we change (2.5,2) to (2.50001,2).

crimestop commented 10 months ago

Well, there seem still to be an error if we change (2.5,2) to (2.50001,2). However it's fine if we change (2.5,2) to (2.5001,2).

loopspace commented 10 months ago

This is an issue with the TikZ/pgf intersection routine. When intersecting two lined, it uses maths to work out the point (rather than a bounding box iteration that it uses for bézier curves). This allows for the possibility that the intersection point is not on the segments, so is a bit more general.

However, it means that it doesn't handle the case of parallel (or near parallel) lines well since that results in dividing by zero (or almost zero).

I presume that this example isn't your actual use case. There are a few work arounds depending on what you want to accomplish. One option is to replace one of the lines by a bézier curve that traverses the same line.

Another is simply to ignore the error since it only happens when the lines don't intersect.

loopspace commented 10 months ago

See, for example, https://github.com/pgf-tikz/pgf/issues/369