15

I made this commands to make paper models, and I ask if it is possible to have a 3D view of them converting in tikz-3D, or backward. But it's easier to draw the flat model and generate the volume after. Calculations could be made with lualatex. If you have an idea to follow ?

enter image description here

enter image description here

\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}
10
  • 7
    Sounds complicated...I would start by representing the underlying structure as a more abstract Lua object so that it is immediate to tell whether a specific component is a "languette" or a face and how the faces are connected. Then from that representation you can produce both views, the flat and the 3D
    – Bordaigorl
    Nov 23, 2014 at 11:52
  • @Bordaigorl This way its seems complicated. I thaught about rotating nodes around vertices as one does when one make the paper model : rotating node A5...A8 around A2-A3 by 120°, then A6...A8 around A2--A5 by ... One has just angles to calculate. Initially all nodes have 0 as z coordinate, then a lualatex macro makes the rotations. Is such a thing possible ? (at the end all languettes are gone).
    – Tarass
    Nov 23, 2014 at 14:03
  • @Bordaigorl The fact is that each rotation is defined by the axe and a node and its image, no need for angle calculation.
    – Tarass
    Nov 23, 2014 at 14:15
  • Did you see the folding library of TikZ by the way?
    – percusse
    Nov 23, 2014 at 15:41
  • @percusse In the manual it is written that there is only one commande to make a dodecahedron. I missed something ?
    – Tarass
    Nov 23, 2014 at 16:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.