# [Tex/LaTex] TikZ: Draw a line up to a curve

tikz-pgf

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.

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}