# TikZ not computing intersection

I'm trying to make two lines intersect using the (intersection cs: first line={}, second line={}) syntax. However, compilation of the following example doesn't do what I want:

%!TEX encoding = UTF-8 Unicode
%!TEX program = lualatex
\documentclass[11pt,a4paper,fleqn,pdftex]{report}
\usepackage[dvipsnames, table]{xcolor}
\usepackage[utf8]{luainputenc}
\usepackage[latin,english]{babel}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\coordinate (S) at (-5 ,0);
\coordinate (M'1) at (0,4.5);
\coordinate (M2) at (0,3);
\def\angleM{10}

\draw[color=Red, thick] (M'1) -- (intersection cs: first line={(M'1)--++(90 - \angleM:-8)}, second line={(-5,-5) -- (5,5)}) circle (2pt) -- (S); % (S) -> (M'1)
\draw[color=Red, thick] (M2) -- (intersection cs: first line={(M2) --++(90 - \angleM:-8)}, second line={(45:-4) -- (45:4)}) circle (2pt) -- (S); % (S) -> (M2)

\draw (S) node[ellipse, fill=white, minimum height=3cm,minimum width=2mm,draw]{$(S)$};
\begin{scope}[thick]
\draw[densely dashed] (M'1) ++(1,0) -- ++(-2,0) node[left]{$M'_1$};
\draw (M2) ++(1,0) -- ++(-2,0) node[left]{$M_2$};
\end{scope}
\fill[pattern=north east lines] (M'1) ++(1,0) rectangle ++(-2,0.2);
\fill[pattern=north east lines] (M2) ++(1,0) rectangle ++(-2,0.2);
\draw[very thick] (45:-2) -- (45:2);
\end{tikzpicture}
\end{figure}
\end{document}


This code yields this:

Whereas I want the red lines to intersect with the black line in the center. Is there something I'm doing wrong? The PGF/TikZ manual doesn't provide any example of the intersection syntax with relative paths.

Don't leave blank spaces in the specification of the lines in the intersection coordinate system: instead of

\draw[color=Red, thick] (M'1) -- (intersection cs: first line={(M'1)--++(90 - \angleM:-8)}, second line={(-5,-5) -- (5,5)}) circle (2pt) -- (S); % (S) -> (M'1)
\draw[color=Red, thick] (M2) -- (intersection cs: first line={(M2) --++(90 - \angleM:-8)}, second line={(45:-4) -- (45:4)}) circle (2pt) -- (S); % (S) -> (M2)


you should use

\draw[color=Red, thick] (M'1) -- (intersection cs: first line={(M'1)--++(90 - \angleM:-8)}, second line={(-5,-5)--(5,5)}) circle (2pt) -- (S); % (S) -> (M'1)
\draw[color=Red, thick] (M2) -- (intersection cs: first line={(M2) --++(90 - \angleM:-8)}, second line={(45:-4)--(45:4)}) circle (2pt) -- (S); % (S) -> (M2)


(to make the explanation more clear, you had second line={(-5,-5) -- (5,5)} with spaces on both sides of the -- and it should be second line={(-5,-5)--(5,5)}) with no spaces; similar remark for the other \draw.

The code:

%!TEX encoding = UTF-8 Unicode
%!TEX program = lualatex
\documentclass[11pt,a4paper,fleqn,pdftex]{report}
\usepackage[dvipsnames, table]{xcolor}
\usepackage[utf8]{luainputenc}
\usepackage[latin,english]{babel}
\usepackage{tikz}
\usetikzlibrary{patterns,calc}
\usetikzlibrary{shapes.geometric}

\begin{document}
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\coordinate (S) at (-5 ,0);
\coordinate (M'1) at (0,4.5);
\coordinate (M2) at (0,3);
\def\angleM{10}

\draw[color=Red, thick] (M'1) -- (intersection cs: first line={(M'1)--++(90 - \angleM:-8)}, second line={(-5,-5)--(5,5)}) circle (2pt) -- (S); % (S) -> (M'1)
\draw[color=Red, thick] (M2) -- (intersection cs: first line={(M2) --++(90 - \angleM:-8)}, second line={(45:-4)--(45:4)}) circle (2pt) -- (S); % (S) -> (M2)

\draw (S) node[ellipse, fill=white, minimum height=3cm,minimum width=2mm,draw]{$(S)$};
\begin{scope}[thick]
\draw[densely dashed] (M'1) ++(1,0) -- ++(-2,0) node[left]{$M'_1$};
\draw (M2) ++(1,0) -- ++(-2,0) node[left]{$M_2$};
\end{scope}
\fill[pattern=north east lines] (M'1) ++(1,0) rectangle ++(-2,0.2);
\fill[pattern=north east lines] (M2) ++(1,0) rectangle ++(-2,0.2);
\draw[very thick] (45:-2) -- (45:2);
\coordinate (L) at  ( $(80 :-8) + (0,4.5)$ );
\end{tikzpicture}
\end{figure}
\end{document}


In fact, you can leave a blank space before the -- but not after it! Perhaps this could be considered a bug?

• Thank you. How could I know when I can and cannot add spaces? I used them for visibility purpose, and didn't even suspect them from making the compilation fail at finding the intersection. – LaX Feb 20 '15 at 20:07
• @LaX in normal circumstances (a simple to path, for example) you can leave spaces, but in this case, they are not allowed (I don't really know if this is a design choice, since they are allowed before, but not after the --). Another case in which this restriction applies is when using the angle pic in which you cannot use spaces, so you have to use {angle = A--B--C} and not {angle = A -- B -- C}. – Gonzalo Medina Feb 20 '15 at 20:16