我想輕鬆繪製 3D 形狀。我覺得很難。我有等角紙,但很難看出在哪裡放置線條。 這是我的 MWE。但這是繪製像我所附的形狀的更簡單的方法。所有的測量都需要在形狀上進行
% !TeX program = xelatex
% !TeX spellcheck = en_GB
\documentclass[12pt,addpoints]{exam}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\usetikzlibrary{quotes,angles}
\usetikzlibrary{quotes,arrows.meta} % needed for tikz pictures
\begin{document}
\begin{tikzpicture}[x={(0.86cm,0.5cm)},y={(-0.86cm,0.5cm)}, color=black]
\clip (0,12.5) rectangle (18,12.5);
\foreach \x in {0,...,25}
\foreach \y in {0,...,25}
{
\fill (\x,\y) circle (2pt);
\draw [red ] (4,11) -- (6,13);
\draw [red ] (4,11) -- (4,15);
\draw [red ] (4,15) -- (6,17);
\draw [red] (6,13) -- (6,17);
\draw [red ] (4,11) -- (10,11);
\draw [red ] (6,13) -- (12,13);
\draw [red ] (10,11) -- (12,13);
\draw [red ] (12,13) -- (12,17);
\draw [red ] (6,17) -- (12,17);
%\draw [red, very thick] (12,17) -- (10,15);
\draw (4,15)-- (10,15);
\draw (10,15)-- (12,17);
\draw (10,15)-- (10,11);
}
\end{tikzpicture}
\end{document}
答案1
該解決方案比建議的更簡單。只需按照 John 所說的在 3D 座標中繪製它,即指定 (x,y,z)。座標框表示(x,y)
是頁面的平面且z
是「深度」。當然,更複雜的形狀需要更多的工作。
如果您正在處理更複雜的事情,您可能需要檢查https://tikz.dev/library-perspective#autosec-6021
% !TeX spellcheck = en_GB
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary {perspective}
\begin{document}
\begin{tikzpicture}
\draw(0,0,0) -- (12,0,0) -- (12,5,0) -- (9,5,0) -- (9,2,0) -- (3,2,0) --(3,5,0) -- (0,5,0) -- cycle;
\draw(0,0,10) -- (12,0,10) -- (12,5,10) -- (9,5,10) -- (9,2,10) -- (3,2,10) --(3,5,10) -- (0,5,10) -- cycle;
\draw (0,0,0)-- (0,0,10);
\draw (12,0,0)-- (12,0,10);
\draw (12,5,0)-- (12,5,10);
\draw (9,5,0)-- (9,5,10);
\draw (9,2,0)-- (9,2,10);
\draw (3,2,0)-- (3,2,10);
\draw (3,5,0)-- (3,5,10);
\draw (0,5,0)-- (0,5,10);
\end{tikzpicture}
\end{document}
正如您所看到的,預設情況下它不是等軸測視圖。這是透視。
isometric view
只需添加諸如 之類的選項\begin{tikzpicture}[isometric view]
。當然,這會翻轉繪圖。
最後,你可以玩弄[3d view = {140}{50}]