tikz 旋轉 3d 箭頭標記

tikz 旋轉 3d 箭頭標記

螢幕截圖我只是使用互聯網程式碼範例將其結合在一起,但我有一個問題:我希望“a”條末尾的刻度線與地面平行,而不是與線垂直。有沒有可能實現這個目標?

\begin{tikzpicture}[cm={-1,-1,1,0,(0,0)},x=3.85mm,z=-1cm, scale=0.5]
      \draw (2,-3,-1) coordinate (x) |- (-2,3,-1) coordinate [midway] (h) coordinate (y) -- (-2,3,1) coordinate (a) -- (-2,-3,1) coordinate (z) -- (2,-3,1) edge (x) -- (2,3,1) coordinate (v) edge (h)
      -- (a)  ;
      \draw [dashed] (-2,-3,-1) coordinate (o) edge (x) edge (y) -- (z);
      \draw [->] (0,0,0) -- (2,0,0) node [midway,above] {$x$};
      \draw [->] (0,0,0) -- (0,2,0) node [midway,right] {$y$};
      \draw [->] (0,0,0) -- (0,0,2) node [midway,above] {$z$};

      \draw [|-|] (2, 3.5, -1) -- (-2, 3.5, -1) node[midway, below right] {a};
\end{tikzpicture}

答案1

可能你必須自己畫水平線,替換

\draw [|-|] (2, 3.5, -1) -- (-2, 3.5, -1) node[midway, below right] {a};

經過

\draw ( 2, 3.4,-1) -- ( 2, 3.6,-1);
\draw (-2, 3.4,-1) -- (-2, 3.6,-1);
\draw ( 2, 3.5,-1) -- node[right]{a} (-2, 3.5,-1) ;

midway請注意,您可以透過將 放node在線運算子後面而不是結束座標後面來避免所有s。

答案2

我不知道如何僅透過一個命令來管理它,但您可以將刻度線繪製為單獨的線:

\begin{tikzpicture}[cm={-1,-1,1,0,(0,0)},x=3.85mm,z=-1cm, scale=0.5]
      \draw (2,-3,-1) coordinate (x) |- (-2,3,-1) coordinate [midway] (h) coordinate (y) -- (-2,3,1) coordinate (a) -- (-2,-3,1) coordinate (z) -- (2,-3,1) edge (x) -- (2,3,1) coordinate (v) edge (h)
      -- (a)  ;
      \draw [dashed] (-2,-3,-1) coordinate (o) edge (x) edge (y) -- (z);
      \draw [->] (0,0,0) -- (2,0,0) node [midway,above] {$x$};
      \draw [->] (0,0,0) -- (0,2,0) node [midway,right] {$y$};
      \draw [->] (0,0,0) -- (0,0,2) node [midway,above] {$z$};

      \draw [-] (2, 3.5, -1) -- (-2, 3.5, -1) node[midway, below right] {a};
      \draw [-] (2, 3.75, -1) -- (2, 3.3, -1);
      \draw [-] (-2, 3.7, -1) -- (-2, 3.25, -1);
\end{tikzpicture}

在這種形式下,如果您想更改座標,則不太方便,因為您必須更改三行而不是一行。如果這是一個問題,您可以使用兩個節點和相對座標,因此您只需更改兩個變數。

\begin{tikzpicture}[cm={-1,-1,1,0,(0,0)},x=3.85mm,z=-1cm, scale=0.5]
      \draw (2,-3,-1) coordinate (x) |- (-2,3,-1) coordinate [midway] (h) coordinate (y) -- (-2,3,1) coordinate (a) -- (-2,-3,1) coordinate (z) -- (2,-3,1) edge (x) -- (2,3,1) coordinate (v) edge (h)
      -- (a)  ;
      \draw [dashed] (-2,-3,-1) coordinate (o) edge (x) edge (y) -- (z);
      \draw [->] (0,0,0) -- (2,0,0) node [midway,above] {$x$};
      \draw [->] (0,0,0) -- (0,2,0) node [midway,right] {$y$};
      \draw [->] (0,0,0) -- (0,0,2) node [midway,above] {$z$};

    \node (a1) at (-2, 3.5, -1){};
    \node (a2) at (2, 3.5, -1){};
    \draw [-] (a1.center) -- (a2.center) node[midway, below right] {a};
    \draw [-] (a1.center) -- +(0,-0.25,0) -- +(0,0.2,0);
    \draw [-] (a2.center) -- +(0,-0.2,0) -- +(0,0.25,0);
\end{tikzpicture}

這兩個範例都應如下所示:

TikZ-樣本

相關內容