3

First emergency attempt is given as follows. I want the hidden lines get automatically rendered with dashed lines whenever I change the camera in animation. How to do so?

enter image description here

\documentclass[border=\dimexpr355pt/113\relax]{standalone} 
\usepackage{filecontents}
\usepackage{asymptote}
\begin{filecontents*}{testfile.asy}
import three;
settings.render=0;
currentprojection=perspective(3,-4,4,center=true);
    draw((0,0,0)--(0,2,0));
    draw((0,0,0)--(2,0,0));
    draw((2,2,0)--(0,2,0));
    draw((2,2,0)--(2,0,0)); 
    draw((0,0,0)--(0,0,2));
    draw((0,2,0)--(0,2,2));
    draw((2,0,0)--(2,0,2));
    draw((2,2,0)--(2,2,2));
    draw((0,0,2)--(0,2,2));
    draw((0,0,2)--(2,0,2));
    draw((2,2,2)--(0,2,2));
    draw((2,2,2)--(2,0,2));
\end{filecontents*}
\begin{document}
    \asyinclude[height=25mm,inline=true,attach=false,viewportwidth=4cm,viewportheight=25mm]{testfile.asy}
\end{document}
10
  • For information: this is very easy with pst-solides3d.
    – Bernard
    Jun 18, 2020 at 12:09
  • 1
    @Bernard: I need an output that can be rotated in PDF. Asymptote provides us with it free of charge. Jun 18, 2020 at 12:17
  • If you mean a programmed animation, it can be done. If you mean rotation directly with the mouse, I don't know.
    – Bernard
    Jun 18, 2020 at 12:26
  • @Bernard: Yes. Interactive with a mouse. Jun 18, 2020 at 12:31
  • 1
    To my knowledge it is not possible to have interactive (OpenGL, WebGL) dashed lines with Asymptote. For a fixed camera and for convex solids you can compute hidden/visible faces by yourself.
    – O.G.
    Jun 18, 2020 at 15:46

1 Answer 1

3

This is Tikz version.

  \documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3dtools}
\begin{document}
    \pgfdeclarelayer{background} 
    \pgfdeclarelayer{foreground}
    \pgfsetlayers{background,main,foreground} 
    \foreach \Angle in {5,15,...,355}
    {\begin{tikzpicture}[same bounding box=A,line cap=round,line join=round,visible/.style={draw,solid}, hidden/.style={draw, dashed}, 3d/install view={phi=\Angle,psi=0,theta=70},declare function={a=2;} ]
            \path
             (a,-a,-a) coordinate (A)
            (a,a,-a) coordinate (B)
            (-a,a,-a) coordinate (C)
            (-a,-a,-a) coordinate (D)
            (a,-a,a) coordinate (E)
            (a,a,a) coordinate (F)
            (-a,a,a) coordinate (G)
            (-a,-a,a)  coordinate (H)
            [3d coordinate={(O)=0.5*(A)+0.5*(G)}];
            \foreach \p in {A,B,C,D,E,F,G,H,O}
            {\draw[fill=black] (\p) circle (1.2 pt);}
            \foreach \p/\g in {A/-90,B/-90,C/-90,D/90,E/90,F/90,G/90,H/90,O/-90}
            {\path (\p)+(\g:3mm) node{$\p$};}
            \tikzset{3d/polyhedron/.cd,O={(O)},
                fore layer=foreground,back layer=background,
                back/.style={3d/polyhedron/complete dashes,fill=none},
                fore/.style={3d/visible,fill=none},%3d/polyhedron/edges have complete dashes=false
                draw face with corners={{(A)},{(B)},{(C)},{(D)}},
                draw face with corners={{(A)},{(B)},{(F)},{(E)}},
            draw face with corners={{(E)},{(F)},{(G)},{(H)}},
                draw face with corners={{(C)},{(D)},{(H)},{(G)}},
                draw face with corners={{(A)},{(E)},{(H)},{(D)}},
                draw face with corners={{(B)},{(C)},{(G)},{(F)}}}
        \end{tikzpicture}}
\end{document}  

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .