2017-06-19 176 views
0

我正在尝试绘制复合三维形状,而且我正在挣扎两个3D点之间的绘制弧线。在下面的例子中,我想从D到H之间顺时针绘制180度的虚线弧,逆时针从D到H 180度的实线弧。然而,当我尝试在两个3D点之间绘制一条弧线

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

回答

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

+1

有一个tikz PGF堆栈Exachange页。我猜你会收到相当数量的答复。 – stars83clouds

相关问题