7

Why the points G and H (seem to) coincide?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections,calc}

\begin{document}

\begin{tikzpicture}[scale=1,font=\small]
\clip (-4,-2.5) rectangle (8,2.5);
\coordinate (A) at (0,0) coordinate (B) at (5.1,0) coordinate (O) at ($(A)!.5!(B)$);
\path (A)--(B);
\draw[thick,name path=L1,blue] (A) circle (2cm); 
\draw[thick,name path=L2,blue] (B) circle (1cm);
\draw[name path=L3] 
  let 
  \p1=($(O)-(A)$) %jari-jari
  in
  (O) circle ({veclen(\x1,\y1)});

\draw[thick,name path=L4,red] (A) circle (1cm);
\path [name intersections={of = L3 and L4, by={C,D}}]; 

\draw[name path=g1] (A)--($(A)!2.1cm!(C)$);
\draw[name path=g2] (A)--($(A)!2.1cm!(D)$);

\path [name intersections={of = L1 and g1, by={E}}]; 
\path [name intersections={of = L1 and g2, by={F}}]; 
\draw[name path=g3] (E)--($(E)!6cm!90:(C)$);
\path [name intersections={of = L2 and g3, by={G}}]; 
\draw[name path=g4,green] (F)--($(F)!6cm!-90:(D)$);
\path [name intersections={of = L2 and g4, by={H}}];

\draw[fill] (A) circle(1pt);
\draw[fill] (O) circle(1pt);
\draw[fill] (B) circle(1pt);
\draw[fill] (C) circle(1pt);
\draw[fill] (D) circle(2pt);
\draw[fill] (E) circle(2pt);
\draw[fill] (F) circle(2pt);
\draw[fill] (G) circle(1pt);
\draw[fill=red] (H) circle(2pt);
\end{tikzpicture}

\end{document}

enter image description here

9

It seems to me that in

\path [name intersections={of = L2 and g3, by={G}}];

the intersection is by intersection-1. Then the coordinate G is defined at intersection-1.

Maybe due to a precision problem there is no real intersection between L2 and g4. So the coordinate intersection-1 known from the last calculation is used to define coordinate H.

If you change the prefix for the intersection between L2 and g4 to e.g. x

\path [name intersections={of = L2 and g4, by={H},name=x}];

you get the error message ! Package pgf Error: No shape named x-1 is known. and H is marked in the orgin.


Consider the following example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\path
  (-2,-2)coordinate[label=below:A](A)
  (-2,2)coordinate[label=above:B](B)
  (2,2)coordinate[label=above:C](C)
  (2,-2)coordinate[label=below:D](D)
  (-3,0)coordinate[label=left:E](E)
  (3,0)coordinate[label=right:F](F)
;
\draw[green,name path=g1](A)--(B)node[left,pos=.25]{g1};
\draw[green,name path=g2](C)--(D)node[right,pos=.25]{g2};
\draw[blue,name path=g3](E)--(F)node[above,pos=.5]{g3};


\path [name intersections={of = g1 and g3, by={G}}];
\path [name intersections={of = g1 and g2, by={H}}];

\path[nodes=circle,draw,fill,inner sep=1pt]
  (G)node[label=above left:G]{}
  (H)node[inner sep=2pt,fill=red,label=below right:H]{}
;

\end{tikzpicture}
\end{document}

resulting in

enter image description here

While there is no intersection between g1 and g2 coordinate H is marked.

If I change the order of the calculations to

\path [name intersections={of = g1 and g2, by={H}}];
\path [name intersections={of = g1 and g3, by={G}];

or if I set a different prefix for the first calculation one using

\path [name intersections={of = g1 and g3, by={G},name=x}];
\path [name intersections={of = g1 and g2, by={H}}];

I get the error message ! Package pgf Error: No shape named intersection-1 is known. and

enter image description here

Note that H is no in the origin.


Suggestion for the picture

Here is a suggestion for your picture using nodes for the blue circles and the tangent cs for the tangents.

\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections,calc}
\begin{document}
\begin{tikzpicture}[scale=1,font=\small,
  blue circle node/.style={draw,thick,blue,circle,transform shape,minimum size=2*#1,outer sep=0pt},
  ]
\newcommand\radius{1cm}
\newcommand\Radius{2cm}
%\clip (-4,-2.5) rectangle (8,2.5);
\coordinate (A) at (0,0) coordinate (B) at (5.1,0) coordinate (O) at ($(A)!.5!(B)$);
\path (A)--(B);
\node[blue circle node=\Radius](L1)at (A){};
\node[blue circle node=\radius](L2)at (B){}; 
\draw[name path=L3] 
  let 
  \p1=($(O)-(A)$), %jari-jari
  \n1={veclen(\x1,\y1)}
  in
  (O) circle [radius=\n1];

\draw[thick,name path=L4,red] (A) circle [radius=1cm];
\path [name intersections={of = L3 and L4, by={C,D}}]; 

\draw(A)--($(A)!{\Radius}!(C)$)coordinate(E)--([turn]0:0.1cm);
\draw(A)--($(A)!{\Radius}!(D)$)coordinate(F)--([turn]0:0.1cm);

\coordinate(G) at (tangent cs:node=L2,point={(E)},solution=2);
\coordinate(H) at (tangent cs:node=L2,point={(F)},solution=1);

\draw(E)--($(E)!6cm!(G)$);
\draw[green](F)--($(F)!6cm!(H)$);


\foreach \p in {A,O,B,C,G}\draw[fill](\p)circle[radius=1pt];
\foreach \p in {D,E,F}\draw[fill](\p)circle[radius=2pt];
\draw[fill=red] (H) circle[radius=2pt];
\end{tikzpicture}
\end{document}

enter image description here

  • 1
    +1 for the tangent cs: never considered that one – daleif Mar 30 '17 at 13:51
  • 2
    I suppose that there is no real intersection between g4 and L2 due to a precision problem, because intersection between g3 and L2 is defined in a similar way a it doesn't fail. Am I wrong? – Ignasi Mar 30 '17 at 14:33
  • @Ignasi I think also that it is a precision problem. Therefore I have added this supposition to answer. – esdd Mar 30 '17 at 19:21
  • @esdd Thank you, I try to go on your way. – kalakay Apr 5 '17 at 23:51

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.