# TikZ: Draw a line up to a curve

Is it possible to draw a line upto a curve. Something like extend...

I do not know to get the pont on the curve to stop the line.

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
%
\begin{tikzpicture}
%grid
\draw [step=1.0,thin,gray!40]
(0,0) grid (6,5);
\coordinate (C) at (1.5,1.5);
\coordinate (D) at (1.2,3);
\fill[blue] (C) circle (2pt);
\fill[blue] (D) circle (2pt);
\draw (C)--(D);
\draw [red,thick](C)--++(3,0);
\draw [blue,thick](D)--++(3,0);
%
\coordinate (A2) at (5,1);
\coordinate (B2) at (3.0,4);
%
\draw (A2) to [bend left=20] (B2);
%
\end{tikzpicture}
%
\end{document}

Red and blue lines must stop exactly on the curve.

-
I believe there is some intersection functionality in TikZ that has been discussed on this site. That might help. – Dylan Moreland Jun 2 '12 at 5:41

## 1 Answer

You can use the intersections library for this, as Dylan suggested.

First, you'll need to name the paths you want to find the intersections for, using name path=<name>. Then you can find the intersections within a draw command using name intersections={of=<first path> and <second path>}. By default, they'll be named intersection-<number>.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
%
\begin{tikzpicture}
%grid
\draw [step=1.0,thin,gray!40]
(0,0) grid (6,5);
\coordinate (C) at (1.5,1.5);
\coordinate (D) at (1.2,3);
\fill[blue] (C) circle (2pt);
\fill[blue] (D) circle (2pt);
\draw (C)--(D);
%
\coordinate (A2) at (5,1);
\coordinate (B2) at (3.0,4);
%
\draw [name path=curve] (A2) to [bend left=20] (B2);
\path [name path=lineA](C)--++(3,0);
\path [name path=lineB](D)--++(3,0);
\draw [name intersections={of=curve and lineA}, red, thick] (C) -- (intersection-1);
\draw [name intersections={of=curve and lineB}, blue, thick] (D) -- (intersection-1);
%
\end{tikzpicture}
%
\end{document}
-
Thank you... Jake – sandu Jun 2 '12 at 7:55
Is it possible to name the intersection point as A or B etc... so that this point can be used in another places. – sandu Jun 2 '12 at 8:01
Yes. Just add a node afterwards, such as ... (intersection-1) node (E) {};. Then try \draw (C) -- (E);. – GregH Jun 2 '12 at 10:53
@sandu: It's better to use coordinate instead of node, because even empty nodes take up some space, which will cause trouble when you try to use them later on. – Jake Jun 2 '12 at 20:19