2017-06-19 183 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

相關問題