# Problem with intersection of two paths

I can not get the attached figure.

\documentclass[tikz,11pt,border=5mm]{standalone}
\usepackage{tikz}
\usepackage{geometry}
\usetikzlibrary{positioning,calc,intersections}

\begin{document}

\begin{tikzpicture}{thick,x=0.5cm,y=0.5cm}

\coordinate [label=below left  : $A$](A) at (0,0);
\coordinate [label=below right : $B$](B) at (10,0);
\coordinate [label=above left : $C$] (C) at (0,5);

\path[name path=line1] (C.east) -- (C.east-|B.west)coordinate[pos=0.6](N) ;
\path[name path=line2] (A) -- (B);
\path[name path=line3]($(A)!(N)!(B)$) -- (N);
\path[name path=line4]($(C)!(N)!(A)$) -- (N);
\path[name path=line5] (A) -- (C);

\path[name intersections={of=line1 and line3,by={P}}];
\path[name intersections={of=line1 and line5,by={M}}];

\draw[fill=green] (A-|P) --(N) -- (C-|M) -- (A) --cycle;
\draw (A)--(B)--(C)--cycle;

\node[above] at (N){$N$};
\node[below] at (P){$P$};

\end{tikzpicture}

\end{document}


• Off-topic but anchors have no meaning if the node is just a coordinate. – marmot Oct 15 '18 at 20:43
• You only need \path (C) -- (B)coordinate[pos=0.6](N) ; \draw[fill=green] (A) rectangle (N); – marmot Oct 15 '18 at 20:51
• @marmot, your solution is much easier using rectangle. – Sigur Oct 15 '18 at 20:55
• @sigur but you were much faster +1 (my internet is really slow these days... ) – marmot Oct 15 '18 at 20:59
• @marmot, if you keep that rep/day ratio with low internet, what happens if you get full speed ! – BambOo Oct 15 '18 at 21:23

Just control the position of P between A and B. I used 60%.

\documentclass[tikz,11pt]{standalone}
\usetikzlibrary{positioning,calc,intersections}

\begin{document}

\begin{tikzpicture}[thick,x=0.5cm,y=0.5cm]

\coordinate [label=below left  : $A$](A) at (0,0);
\coordinate [label=below right : $B$](B) at (10,0);
\coordinate [label=left  : $C$](C) at (0,5);
\coordinate [label=below : $P$](P) at ($(A)!.6!(B)$);

\path[name path=hipo]  (C) -- (B);
\path[name path=rightVertical] (P) -- (P|-C) ;
\path[name path=leftVertical] (A) -- (C);

\path[name intersections={of=rightVertical and hipo,by={N}}];
\path[name path=horizontal] (N) -- (N-|C) ;
\path[name intersections={of=horizontal and leftVertical,by={M}}];

\draw[fill=green] (P)--(N)--(M)--(A)--cycle;
\draw (A)--(B)--(C)--cycle;
\node[above] at (N){$N$};
\node[left]  at (M){$M$};
\end{tikzpicture}

\end{document}


• You could also fix \begin{tikzpicture}{...} to \begin{tikzpicture}[...]. – Torbjørn T. Oct 15 '18 at 20:51
• @TorbjørnT. good point. Done! – Sigur Oct 15 '18 at 20:54

Similar to @Sigur but there are no intersections used (as not needed).

\documentclass[tikz,11pt,border=5mm]{standalone}
\usetikzlibrary{positioning,calc}

\begin{document}

\begin{tikzpicture}[thick,x=0.5cm,y=0.5cm]
\coordinate [label=below left  : $A$](A) at (0,0);
\coordinate [label=below right : $B$](B) at (10,0);
\coordinate [label=above left : $C$] (C) at (0,5);
\path (C) -- (B)coordinate[pos=0.6,label=above right:$N$](N) ;
\draw[fill=green] (A) rectangle (N);
\coordinate[label=above left:$M$] (M) at (A|-N);
\draw (A) -- (B) -- (C) -- cycle;
\end{tikzpicture}
\end{document}


Output as your desired screen shot.

• @manooooh added (really slow internet in Mexico.. ) – marmot Oct 15 '18 at 21:01
• Not too slow. I was preparing the output for you, but you were faster... lol – Sigur Oct 15 '18 at 21:01
• @marmot Thank you, your solution is much simpler than the one I proposed ! – Fabrice Oct 15 '18 at 21:50