我制作了这些命令来制作纸模型,我问是否可以在 tikz-3D 中或向后转换它们以获得 3D 视图。但绘制平面模型并在之后生成体积更容易。可以使用进行计算lualatex
。如果你有想法可以遵循吗?
\documentclass[margin=2pt]{standalone}
\usepackage{tikz,xparse}
\usetikzlibrary{calc}
\tikzset{%
patron/.style={%
line join=round,
rounded corners=.05pt,
draw, thin},
patron side/.style={patron},
patron languette/.style={patron},
}
\newcounter{NodePat}
\NewDocumentCommand{\PolygReg}{%
O{3} % nb de cotés
m % segment A/B
O{A} % nom générique
}{%
\foreach \a/\b in {#2} {%
\path[patron side] let
\p1 = ($(\a)!.5!(\b)$) ,
\n1 = {veclen(\x1,\y1)} ,
\p2 = ($(\p1)!1/tan(180/#1)!90:(\b)$)
in
(\a)--(\b)
\foreach \i [%
evaluate=\i as \j using (\i-1)*360/#1] in {3,...,#1} {%
-- ($(\p2)!1!\j:(\a)$) coordinate (#3\theNodePat)
\pgfextra{\stepcounter{NodePat}}
}
-- cycle ;
}
}
\NewDocumentCommand{\Languette}{%
O{.15} % largeur
D<>{45} % angle sur le premier node
m % les deux nodes
D<>{45} % angle sur le second node
O{A}
}{%
\foreach \b/\a in {#3} {%
\path[patron languette] let
\p1 = ($(#5\b)!#1/sin(#2)!-#2:(#5\a)$),
\p2 = ($(#5\a)!#1/sin(#4)!#4:(#5\b)$)
in
(#5\a) -- (#5\b)
-- (\p1)
-- (\p2)
-- cycle ; }
}
\makeatletter
\newcommand{\AffNodesPatron}[1][A]{%
\newcount\X
\X=1
\loop
\expandafter\ifx\csname pgf@sh@pi@A\the\X\endcsname\pgfpictureid
\node[font={\footnotesize},red] at (A\the\X) {A\the\X} ;
\advance \X by 1
\else
\X=0
\fi
\unless\ifnum \X=0
\repeat
}
\makeatother
\begin{document}
\begin{tikzpicture}[scale=2]
\coordinate (A1) at (0,0) ;
\coordinate (A2) at (1,0) ;
\setcounter{NodePat}{3}
\PolygReg[4]{A1/A2}
\PolygReg{A3/A2,A5/A2,A5/A6,A5/A7}
\Languette{1/2,5/3,3/4,4/1}
%\AffNodesPatron
\end{tikzpicture}
\begin{tikzpicture}
\coordinate (A1) at (0,0) ;
\coordinate (A2) at (1,0) ;
\setcounter{NodePat}{3}
\PolygReg[6]{A1/A2,A4/A3,A6/A5,A2/A1}
\PolygReg[4]{A17/A16}
\PolygReg[6]{A20/A19,A20/A24,A23/A22,A21/A19}
\PolygReg[4]{A5/A4,A3/A2,A1/A6,A24/A23,A22/A21}
\Languette<30>{3/7,7/8,8/9,9/10,10/4,37/38,5/11,11/12,12/13,13/14,14/6,41/42,%
42/1,15/16,16/19,21/45,22/29,32/23,28/20,17/18,2/39,39/40}<30>
%\AffNodesPatron
\end{tikzpicture}
\end{document}