我想在 TikZ 3D 圖中繪製一個點/小球體

我想在 TikZ 3D 圖中繪製一個點/小球體

我有一個 3d 座標系,我想用點標記一個點。

\begin{tikzpicture}[x = {(0.866cm,0.5cm)}, y={(0cm,1cm)}, z={(0.866cm,-0.5cm)},]
\draw[thick,->] (-15,0,0) -- (15,0,0) node[right] {x};
\draw[thick,->] (0,-12,0) -- (0,12,0) node[above] {y};
\draw[thick,->] (0,0,-15) -- (0,0,50) node[right] {z};
\fill (0,0,5) circle (1);
\end{tikzpicture}

這是結果:

壞點

但從角度來看我想要的是一個球體或一個圓:

好點

我怎樣才能實現這個目標?

答案1

通常,2 小時在網路上搜尋。然後在最終發布後,2分鐘後我自己找到了答案。但由於它很難找到,也許對其他人會有幫助:

\begin{tikzpicture}[x = {(0.866cm,0.5cm)}, y={(0cm,1cm)}, z={(0.866cm,-0.5cm)},]
\draw[thick,->] (-15,0,0) -- (15,0,0) node[right] {x};
\draw[thick,->] (0,-12,0) -- (0,12,0) node[above] {y};
\draw[thick,->] (0,0,-15) -- (0,0,50) node[right] {z};
\draw plot [mark=*, mark size=10] coordinates{(0,0,5)}; 
\end{tikzpicture}

我不知道它是如何運作的,但它完美地滿足了我的要求: 在此輸入影像描述

答案2

tikz-3dplot這裡顯示了球體和圓都可以改變大小的解。

在此輸入影像描述

程式碼

\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\tdplotsetmaincoords{120}{50}

\begin{document}

\begin{tikzpicture}[scale=2, tdplot_main_coords,axis/.style={->},thick]
\draw[axis] (-1, 0, 0) -- (1, 0, 0) node [right] {$X$};
\draw[axis] (0, -1, 0) -- (0, 3, 0) node [right] {$Z$};
\draw[axis] (0, 0, -1) -- (0, 0, 1) node [above] {$Y$};

\node[draw=none,shape=circle,fill, inner sep=2pt] (d1) at (0,1,0){};  % circle

\tdplottransformmainscreen{0}{2}{0}
\shade[tdplot_screen_coords, ball color = red] (\tdplotresx,\tdplotresy) circle (0.05);                                                                   % sphere
\end{tikzpicture}
\end{document}

答案3

您可以用來node表達您的觀點。

如果你想把點放在線上,那麼使用標記是完美的,但如果你想把點放在線外...

\documentclass[tikz, varwidth, border=10]{standalone}
\begin{document}
  \begin{tikzpicture}[scale=.2, x = {(0.866cm,0.5cm)}, y={(0cm,1cm)}, z={(0.866cm,-0.5cm)}]
    \draw[thick,->] (-15,0,0) -- (15,0,0) node[right] {x};
    \draw[thick,->] (0,-12,0) -- (0,12,0) node[above] {y};
    \draw[thick,->] (0,0,-15) -- (0,0,50) node[right] {z};
    \path (0,0,5) node[circle, fill, inner sep=1]{};
    \path (1,0,5) node[circle, fill, inner sep=1]{};
  \end{tikzpicture}
\end{document}

在此輸入影像描述

註:您可以閱讀這個問題/答案

相關內容