I was trying to use TikZ to sketch some graph but something weird happened. I was trying to use "intersection" to get the coordinate of the intersection of two lines, but strangely, there is always one point that cannot get the correct coordinate.
The following is the TikZ code I wrote, and as the output shows, the coordinate for the point (By) is wrong. I changed the order in which I define the four points Bx, By, Dx, Dy, and find that it is always the first of these four gets the coordinate messed up.
I suspect this might be caused by putting labels on the first four points (CC, CD, DC, DD), but I have no idea how to correct this.
I am new to TikZ, so any help is greatly appreciated!
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}%[plain]
\begin{tikzpicture}
\coordinate [label=right:{$(r-1,r-1)$}] (CC) at (2,2);
\coordinate [label=left:{$(-1,r)$}] (CD) at (-1,3);
\coordinate [label=right:{$(r,-1)$}] (DC) at (3,-1);
\coordinate [label=225:{$(0,0)$}] (DD) at (0,0);
\coordinate (By) at (intersection of (0,-1)--(0,4) and CD--CC);
\coordinate (Dx) at (intersection of (-1,0)--(4,0) and CD--DC);
\coordinate (Dy) at (intersection of (0,-1)--(0,4) and CD--DC);
\coordinate (Bx) at (intersection of (-1,0)--(4,0) and DC--CC);
\fill (Bx) circle (2pt);
\fill (By) circle (2pt);
\fill (Dx) circle (2pt);
\fill (Dy) circle (2pt);
\draw [thick] (-1,0) -- (4,0) node [below] {$u_1$};
\draw [thick] (0,-1) -- (0,4) node [left] {$u_2$};
\draw [thick] (DD) -- (CD) -- (CC) -- (DC) -- cycle;
\draw [dashed] (CD) -- (DC);
\draw [thick] (CC) -- (DD);
\draw [thick] (Dx) -- (Dy);
\end{tikzpicture}
\end{frame}
\end{document}

\coordinate (By)thru\fill (Dy)to be after those lines are actually drawn things seem to work. Of course the\draw [thick] (Dx) -- (Dy);will still need to be after the(Dx)and(Dy)coordinates are computed. – Peter Grill Sep 25 '14 at 16:15(intersection ofI can't find it. There is theintersectionslibrary, but it doesn't work like this. – Kpym Dec 17 '14 at 07:11