在两个3D点之间绘制弧

时间:2017-06-19 11:08:09

标签: tikz

我正在尝试绘制复合3D形状,我正在努力在两个3D点之间绘制弧线。在下面的示例中,我想在顺时针方向从D到H之间绘制180度的虚线弧,并且从D到H逆时针方向绘制180度的实心弧。但是,当我尝试

\draw (D)  arc[radius=\R, start angle=180, end angle=0];

我没有得到我想要的弧线。以下是我到目前为止的代码:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}
\tdplotsetmaincoords{65}{-43}
\begin{center}
\begin{tikzpicture}[
    scale=1,
    tdplot_main_coords]
    \def\R{2}
    \def\h{6}
    \coordinate (A) at ({\R*cos(0)},{\R*sin(0)},0);
    \coordinate (B) at ({\R*cos(45)},{\R*sin(45)},0);
    \coordinate (C) at ({\R*cos(90)},{\R*sin(90)},0);    
    \coordinate (D) at ({\R*cos(135)},{\R*sin(135)},0);
    \coordinate (E) at ({\R*cos(180)},{\R*sin(180)},0);
    \coordinate (F) at ({\R*cos(225)},{\R*sin(225)},0);
    \coordinate (G) at ({\R*cos(270)},{\R*sin(270)},0);
    \coordinate (H) at ({\R*cos(315)},{\R*sin(315)},0);
    \coordinate (O) at (0,0,0);
    \coordinate (O') at (0,0,\h);
    \coordinate (O'') at (0,0,-\h);
    \foreach \i in {A,B,C}{
        \draw[dashed] (\i) -- (O');
    \node at (\i) [above]{$\i$};}
    \foreach \i in {D,E,F,G,H}{
        \draw (\i) -- (O');
    \node at (\i) [below]{$\i$};}   
    \draw[red] (O) circle (\R);
    \draw[red] (D) -- (O'') -- (H);
    \draw[dashed] (H) -- (A) -- (B) -- (C) -- (D);
    \draw (D) -- (E) -- (F) -- (G) -- (H);
    \node at (O') [above]{$O'$};
    \node at (O'') [below,thick,red]{$O''$};
    \end{tikzpicture}
\end{center}
\end{document}

Composite shape.

1 个答案:

答案 0 :(得分:0)

由于没有人回答或评论,我想出了我自己的解决方案,它使用双坐标系而不是三坐标系,但它有效......

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=1]
    \def\xRadius{2}
    \def\yRadius{0.4*\xRadius}
    \def\h{5.4}
    \coordinate (A) at ({\xRadius*cos(45)},{\yRadius*sin(45)});
    \coordinate (B) at ({\xRadius*cos(90)},{\yRadius*sin(90)});    
    \coordinate (C) at ({\xRadius*cos(135)},{\yRadius*sin(135)});
    \coordinate (D) at ({\xRadius*cos(180)},{\yRadius*sin(180)});
    \coordinate (E) at ({\xRadius*cos(225)},{\yRadius*sin(225)});
    \coordinate (F) at ({\xRadius*cos(270)},{\yRadius*sin(270)});
    \coordinate (G) at ({\xRadius*cos(315)},{\yRadius*sin(315)});
    \coordinate (H) at ({\xRadius*cos(0)},{\yRadius*sin(0)});
    \coordinate (O) at (0,0);
    \coordinate (O') at (0,\h);
    \coordinate (O'') at (0,-\h);
    \foreach \i in {A,B,C}{
        \draw[dashed] (\i) -- (O');
    \node at (\i) [above]{$\i$};}
    \foreach \i in {D,E,F,G,H}{
        \draw (\i) -- (O');
    \node at (\i) [below]{$\i$};}   
    \draw[red,dashed] (H) arc [x radius = \xRadius, y radius = \yRadius, start angle=0, end angle=180];
    \draw[red] (H) arc [x radius = \xRadius, y radius = \yRadius, start angle=0, end angle=-180];
    \draw[red] (D) -- (O'') -- (H);
    \draw[dashed] (H) -- (A) -- (B) -- (C) -- (D);
    \draw (D) -- (E) -- (F) -- (G) -- (H);
    \node at (O') [above]{$O'$};
    \node at (O'') [below,thick,red]{$O''$};
\end{tikzpicture}
\end{center}
\end{document}

enter image description here