我使用3d
TikZ 库在 zy 平面上围绕 x 轴的一条线绘制一个圆。但由于圆是在线的上方绘制的,所以看起来线并没有穿过圆。
我该如何解决这个问题?我想到的解决方案是画两个半圆或两个线段,但如果形状复杂,这会变得很混乱。有没有更通用的解决方案或更好的包来实现这一点?
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{3d}
\begin{document}
\begin{tikzpicture}
\begin{scope}[canvas is xy plane at z=0]
\draw[color=green,very thick] (0,0) -- (2,0);
\end{scope}
\begin{scope}[canvas is zy plane at x=1]
\draw[color=blue,very thick] (0,0) circle (1);
\end{scope}
\end{tikzpicture}
\end{document}
答案1
这是你要找的:
\documentclass[convert = false]{standalone}
\usepackage{tikz, tikz-3dplot}
\usetikzlibrary{3d}
\usetikzlibrary{arrows, decorations.markings, intersections, backgrounds}
\begin{document}
\tdplotsetmaincoords{60}{130}
\begin{tikzpicture}
\begin{scope}[canvas is xy plane at z=0]
\path[color=green,very thick, name path global = line]
(0,0) coordinate (O) -- (2,0) coordinate (E);
\end{scope}
\begin{scope}[canvas is zy plane at x=1]
\draw[color=blue, name path global = circ] (0,0) circle (1);
\end{scope}
\path[name intersections = {of = line and circ}];
\begin{scope}[on background layer]
\draw (O) -- ($(intersection-2)$) coordinate (P1);
\end{scope}
\draw ($(intersection-2)-(.015,0)$) -- (E);
\end{tikzpicture}
\end{document}