交叉路口出了什么问题?

交叉路口出了什么问题?

为什么点GH(似乎)重合?

\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}

在此处输入图片描述

答案1

在我看来

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

交点为intersection-1。则坐标G定义为intersection-1

L2可能由于精度问题,和之间没有真正的交点g4。因此使用上次计算中已知的坐标intersection-1来定义坐标H

L2如果将和之间的交叉点的前缀更改g4为例如x

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

您会收到错误消息! Package pgf Error: No shape named x-1 is known.,并H在原处进行标记。


请考虑以下示例:

\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}

导致

在此处输入图片描述

g1而与g2坐标之间没有交点H则被标记。

如果我将计算的顺序改为

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

或者如果我为第一个计算设置不同的前缀,使用

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

我收到错误消息! Package pgf Error: No shape named intersection-1 is known.

在此处输入图片描述

请注意,H起源中没有。


图片建议

这里建议您使用节点作为蓝色圆圈和tangent cs作为切线的图片。

\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}

在此处输入图片描述

相关内容