![命名线交点并在以后使用它](https://linux22.com/image/478355/%E5%91%BD%E5%90%8D%E7%BA%BF%E4%BA%A4%E7%82%B9%E5%B9%B6%E5%9C%A8%E4%BB%A5%E5%90%8E%E4%BD%BF%E7%94%A8%E5%AE%83.png)
我已经绘制了椭圆的切线,我想找到这些切线的交点并将它们连接成一条线。我知道如何画出那条线,但我不知道如何获取这些交点的坐标以便以后使用它们。下面的代码不起作用,它无法将 X 和 Y 识别为坐标。
谢谢大家的帮助。
\documentclass{standalone}
\RequirePackage{tikz}
\usetikzlibrary{calc,through,arrows,fadings,decorations.pathreplacing,matrix}
\usetikzlibrary{intersections}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=1.4]
\clip (-3,-2) rectangle (3,2);
\coordinate (A) at (130:2 and 1);
\coordinate (B) at (100:2 and 1);
\coordinate (C) at (40:2 and 1);
\draw[black,thick] (0,0) ellipse (2 and 1);
\draw[blue,name path=tanAl] (A) -- ++ ({-2*sin(130)},{cos(130)});
\draw[blue,name path=tanAd] (A) -- ++ ({2*sin(130)},{-cos(130)});
\draw[blue,name path=tanBl] (B) -- ++ ({-2*sin(100)},{cos(100)});
\draw[blue,name path=tanBd] (B) -- ++ ({2*sin(100)},{-cos(100)});
\draw[blue,name path=tanCl] (C) -- ++ ({-2*sin(40)},{cos(40)});
\draw[blue,name path=tanCd] (C) -- ++ ({2*sin(40)},{-cos(40)});
\coordinate (X) at (intersection of tanAd and tanBl);
\coordinate (Y) at (intersection of tanBd and tanCl);
\foreach \p in {A,B,C,D,E,F,X,Y}
\fill[black] (\p) circle (0.04);
\draw[black] ($(A)+(90:0.3)$) node{$A$};
\draw[black] ($(B)+(110:0.3)$) node{$B$};
\draw[black] ($(C)+(90:0.3)$) node{$C$};
\end{tikzpicture}
\end{center}
\end{document}
答案1
您必须将节点X
和定义Y
为path
。
\path [name intersections={of=tanAd and tanBl,by={X}}];
\path [name intersections={of=tanBd and tanCl,by={Y}}];
另外,你不需要在standalone
课堂上居中。
\documentclass{standalone}
\RequirePackage{tikz}
\usetikzlibrary{calc,through,arrows,fadings,decorations.pathreplacing,matrix}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[scale=1.4]
\clip (-3,-2) rectangle (3,2);
\coordinate (A) at (130:2 and 1);
\coordinate (B) at (100:2 and 1);
\coordinate (C) at (40:2 and 1);
\draw[black,thick] (0,0) ellipse (2 and 1);
\draw[blue,name path=tanAl] (A) -- ++ ({-2*sin(130)},{cos(130)});
\draw[blue,name path=tanAd] (A) -- ++ ({2*sin(130)},{-cos(130)});
\draw[blue,name path=tanBl] (B) -- ++ ({-2*sin(100)},{cos(100)});
\draw[blue,name path=tanBd] (B) -- ++ ({2*sin(100)},{-cos(100)});
\draw[blue,name path=tanCl] (C) -- ++ ({-2*sin(40)},{cos(40)});
\draw[blue,name path=tanCd] (C) -- ++ ({2*sin(40)},{-cos(40)});
%\coordinate (X) at (intersection of tanAd and tanBl);
%\coordinate (Y) at (intersection of tanBd and tanCl);
\path [name intersections={of=tanAd and tanBl,by={X}}];
\path [name intersections={of=tanBd and tanCl,by={Y}}];
\foreach \p in {A,B,C,X,Y} % The nodes D,E,F are not defined. Removed them.
\fill[black] (\p) circle (0.04);
\draw[black] ($(A)+(90:0.3)$) node{$A$};
\draw[black] ($(B)+(110:0.3)$) node{$B$};
\draw[black] ($(C)+(90:0.3)$) node{$C$};
\end{tikzpicture}
\end{document}
答案2
这只是因为您在上一个问题下的评论中提出了这些后续问题。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=1.4,eltangent/.style={insert path={%
($(#1:2 and 1)+({-2*sin(#1)},{cos(#1)})$) coordinate(et-#1-A)
--($(#1:2 and 1)+({2*sin(#1)},{-1*cos(#1)})$) coordinate(et-#1-B)}},
bullet/.style={circle,fill,inner sep=0.05cm}]
\clip (-3,-2) rectangle (3,2);
\coordinate (A) at (130:2 and 1);
\draw[black,thick] (0,0) ellipse (2 and 1);
\node[label=above:$A$,bullet] at (A){};
\draw[blue,eltangent=130];
\draw[blue,eltangent=80];
\path (intersection cs:first line={(et-130-A)--(et-130-B)},second
line={(et-80-A)--(et-80-B)}) node[bullet,label=above:$I$]{};
\node[above]{$\gamma(t)=\bigl(2\,\cos(t),\sin(t)\bigr)$};
\node[below]{$\dot\gamma(t)=\bigl(-2\,\sin(t),\cos(t)\bigr)$};
\end{tikzpicture}
\end{document}
如果你不想画切线,可以使用
\path[eltangent=130];
\path[eltangent=80];
\path (intersection cs:first line={(et-130-A)--(et-130-B)},second
line={(et-80-A)--(et-80-B)}) node[bullet,label=above:$I$]{};
请保持Ferahfeza 的精彩回答被接受的。