我分别从(0,0)
到(50:8cm)
和画了两条线(80:8cm)
。然而,这两条线重合了。我不知道为什么会发生这种情况。我希望你能帮我解决这个问题。
\documentclass[12pt, a4paper]{article}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{amssymb, amsmath, amsthm}
\usepackage{tikz}
\usetikzlibrary{angles,calc,intersections,quotes}
\begin{document}
\begin{tikzpicture}
\draw (-0.5,0) -- (4,0); %x軸
\coordinate (O) at (0,0);
\draw [name path=L] (3,-0.5) -- (3,10) node [above,inner sep=1pt] {$L$}; %L
\path [name path=OB'] (O) -- (20:8cm); %OB的延伸線,為了與L相交以取得B的座標
\path [name intersections={of=L and OB', by=B}]; %B
\draw (O) -- (B) node [right,inner sep=1pt] {$B$};
\path [name path=OC'] (O) -- (50:8cm); %OC的延伸線,為了與L相交以取得C的座標
\path [name intersections={of=L and OC', by=C}];
\draw [red] (O) -- (C) node [right,inner sep=1pt] {$C$}; %OC
\path [name path=OA'] (O) -- (80:8cm); %OA的延伸線,為了與L相交以取得A的座標
\path [name intersections={of=L and OA', by=A}];
\draw [dashed] (O) -- (A) node [right,inner sep=1pt] {$A$}; %OA
\end{tikzpicture}
\end{document}
答案1
路径不会自动延伸。因此您必须赋予它们足够的长度以使它们真正相交。
\documentclass[12pt, a4paper]{article}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{amssymb, amsmath, amsthm}
\usepackage{tikz}
\usetikzlibrary{angles,calc,intersections,quotes}
\begin{document}
\begin{tikzpicture}
\draw (-0.5,0) -- (4,0); %x軸
\coordinate (O) at (0,0);
\begin{pgfinterruptboundingbox}
\path [name path=L] (3, -0.5) -- (3, 20);
\path [name path=OB'] (O) -- (20:20cm); %OB的延伸線,為了與L相交以取得B的座標
\path [name path=OC'] (O) -- (50:20cm); %OC的延伸線,為了與L相交以取得C的座標
\path [name path=OA'] (O) -- (80:20cm); %OA的延伸線,為了與L相交以取得A的座標
\path [name intersections={of=L and OB', by=B}]; %B
\path [name intersections={of=L and OC', by=C}];
\path [name intersections={of=L and OA', by=A}];
\end{pgfinterruptboundingbox}
\draw (3,-0.5) -- (3,10) node [above,inner sep=1pt] {$L$}; %L
\draw (O) -- (B) node [right,inner sep=1pt] {$B$};
\draw [red] (O) -- (C) node [right,inner sep=1pt] {$C$}; %OC
\draw [dashed] (O) -- (A) node [right,inner sep=1pt] {$A$}; %OA
\end{tikzpicture}
\end{document}