[Tex/LaTex] tikz intersection of named path

intersectionstikz-pgf

I want to use named path to calculate the intersection of 2 line. but below example code doesn't work!

\documentclass[border=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}
\tikzset{
    dot/.style={circle,inner sep=1pt,fill,label={\tiny #1},name=#1},
}

\node[dot=A] (A) at (0,0) {};
\node[dot=B] (B) at (1,0) {};
\node[dot=C] (C) at (0,1) {};
\node[dot=D] (D) at (1,0.5) {};

\path[name path=P1] (A) -- (B);
\path[name path=P2] (C) -- (D);

\coordinate (CS) at (intersection of P1 and P2); 
%\coordinate (CS) at (intersection of A--B and C--D); 

\draw (A) -- (B);
\draw (C) -- (D);
\node[dot=E] (E) at (CS) {};
\draw[dotted] (B)--(E)--(D);
\end{tikzpicture}
\end{document}

If I use the comment out line as below:

\coordinate (CS) at (intersection of A--B and C--D);

It works fine. Is it possible to use a named path as argument of intersection macro!

Expected output as below:
enter image description here

Best Answer

With a real intersection you can write (I changed the coordinates of D)

\begin{tikzpicture}
\tikzset{dot/.style={circle,inner sep=1pt,fill,label={\tiny #1},name=#1}}
\node[dot=A] (A) at (0,0) {};
\node[dot=B] (B) at (1,0) {};
\node[dot=C] (C) at (0,1) {};
\node[dot=D] (D) at (1,-0.5) {};

\draw [name path=P1] (A) -- (B);
\draw [name path=P2] (C) -- (D);

\path [name intersections={of=P1 and P2,by=E}];
\node[dot=E]  at (E) {};
\draw[dotted] (B)--(E)--(D);
\end{tikzpicture}

else

\begin{tikzpicture}
\tikzset{
    dot/.style={circle,inner sep=1pt,fill,label={\tiny #1},name=#1}}
\node[dot=A] (A) at (0,0) {};
\node[dot=B] (B) at (1,0) {};
\node[dot=C] (C) at (0,1) {};
\node[dot=D] (D) at (1,0.5) {};

\draw [name path=A--B] (A) -- (B);
\draw [name path=C--D] (C) -- (D);

\coordinate (E) at (intersection of A--B and C--D);
\node[dot=E]  at (E) {};
\draw[dotted] (B)--(E)--(D);
\end{tikzpicture}

enter image description here