I'm specifically interested in the case in which lines AB and CD intersect, but outside (of at least one) of the segments AB, CD, and get the intersection I for further work. The similar questions only handle the case in which the segments intersect.

  • see [](tex.stackexchange.com/questions/31398/…) – Denis Sep 13 '18 at 11:21
  • 5
    Pleasssse add a minimal working example! With 3.5k rep how can you not know the drill? – Andrew Sep 13 '18 at 11:26
  • @Denis, there the intersection is inside both segments. – vonbrand Sep 13 '18 at 11:59
  • @vonbrand, in the answer is inside too if you read it carefully. – koleygr Sep 13 '18 at 12:05
  • @koleygr, I did try to decypher the answers, they mostly handle just the case (no interest to me) when the intersection is inside both segments, or perpendicular lines (in my case, they intersect outside the segments,at any angle)- – vonbrand Sep 13 '18 at 14:38
  1. Declare two path which intersect.
  2. Computes and draw the intersection point.
  3. Draw (or not) some fragment of original paths.

That's all.

\usetikzlibrary{intersections, calc}

\path[name path=a] (0,0) coordinate (a1) -- (2,4) coordinate (a2);
\path[name path=b] (0,4) coordinate (b1) -- (5,2) coordinate (b2);
\fill[red,name intersections={of=a and b}]
    (intersection-1) circle (2pt);

\draw (a1)--($(a1)!.5!(a2)$);
\draw (b2)--($(b2)!.5!(b1)$);

enter image description here

  • Weird... I tried something very similar, got nowhere... – vonbrand Sep 13 '18 at 11:56
  • 1
    (+1) The funny think is the optical illusion that the dot in over their intersection. – koleygr Sep 13 '18 at 12:02
  • Nope. The intersection is inside the segments a1-a2 and b1-b2. – vonbrand Sep 13 '18 at 14:35

There is another way to find the intersection of two intersecting lines that is no longer documented in manual 3.0.1a but still works. It is on page 87 of manual 1.18 which you will find here (until when?): tikz pgf manual 1.18

It consists in solving a system of 2 equations with 2 unknowns (the points that define the 2 lines). It is not necessary for the paths to intersect on the figure to find their intersection unlike the version given in manual 3.01a of the solution given by ignasi. The second advantage is that it is not necessary to load any library for this to work.

You will notice that the points or their coordinates are named without parentheses:

intersection of A--B and 0,3--2,2

Line A--B shorter as suggested by @marmot


\draw[help lines] (0,0) grid (3,3);
\draw (0,0) coordinate (A)node[below]{A} -- (2,1.5) coordinate (B)node[below right]{B}
(0,3)node[below left]{C} -- (2,2)node[below left]{D};
\fill[blue] (intersection of A--B and 0,3--2,2) circle (2pt);

Translated with www.DeepL.com/Translator

  • @marmot, I don't know more than the given points A, B, C, D. Just drawing part of the line is no help. – vonbrand Sep 13 '18 at 14:42
  • @vonbrand Finally, I don't know if I understood your question correctly. Have you read the update of my answer? – AndréC Sep 13 '18 at 14:50
  • I believe this is deprecated in current TikZ... there is no section 1.18 in current version 3.0.1a of the TikZ & PGF manual. Page 118 gives an example of segments that do intersect. – vonbrand Sep 13 '18 at 14:50
  • @vonbrand No, it works. it had been deleted, then at the request of the users, it was delivered (but without the doc). it's not the only thing like that with tikz, there is also shorten > which still works but is only documented in the manual 1.18. – AndréC Sep 13 '18 at 14:52
  • @vonbrand It is still official, though with a slightly different syntax. See page 118 (instead of section 1.18) of the pgfmanual. Try \draw (0,0) coordinate(A) -- (1,2) coordinate(B); \draw (3.5,0) coordinate(C)-- (3,2) coordinate(D); \coordinate (X) at (intersection cs:first line={(A)--(B)}, second line={(C)--(D)}); \fill[red] (X) circle (1pt);. – user121799 Sep 13 '18 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.