2

Thanks to this (by @user2478) and this (by @user121799) great answers, I'm trying to draw a sketch as a combination of both.

The point is that the former and the later are in PSTricks and TikZ, respectively. So, I maybe should have converted one of them to another, so that the combination would be more straightforward. But, unfortunately I can't make such conversions out. That being said, I have a pspicture and a tikzpicture, and I need to shift the objects of the tikzpicture in such a way that they get into the area of the pspicture's entity. In particular, here is what have done so far.

\documentclass{article}

\usepackage{tikz}
\usepackage{pst-solides3d}    
\usepackage{tikz-3dplot} 
\usetikzlibrary{shapes,3d}

\begin{document}

\psset{viewpoint=10 70 15 rtp2xyz,Decran=10}
\begin{pspicture}[solidmemory](-5,-5)(6,1)
\psSolid[object=parallelepiped,a=6,b=3,c=3,RotZ=30,name=Cube,action=draw](0 0 2)
\multido{\iA=0+1}{8}{%
  \psSolid[object=point,definition=solidgetsommet,args=Cube \iA]}
\psdots*[dotstyle=diamond, fillcolor=red, linecolor = red](0,2)(1,1)(0.5,0.5)(-1,1)(-2,2)(-1.5,3)(1.5,3.5)
\end{pspicture}

\psset{viewpoint=10 60 15 rtp2xyz,Decran=10}
\begin{pspicture}[solidmemory](-7.5,-5)(6,1)
\psSolid[object=parallelepiped,a=10,b=2,c=2.2,RotZ=30,name=Cube,action=draw](0 0 2)
\multido{\iA=0+1}{8}{%
    \psSolid[object=point,definition=solidgetsommet,args=Cube \iA]}
\psdots*[dotstyle=diamond, fillcolor = red, linecolor = red](-2.3,2)(-1.3,1)(-1.8,0.5)(-3,1)(-4.3,2)(-3.8,3)(-0.8,3)

\psdots*[dotstyle=square, fillcolor = blue, linecolor = blue](-0.3,1)(-0.1,1.5)(0.3,2)(0.2,3)(1.5,2)(1,2.7)(0.6,1)(0.8,1.4)(1.7,2.4)(2.3,2.7)(2,1.7)
\end{pspicture}

\tdplotsetmaincoords{100}{300}
\begin{tikzpicture}[tdplot_main_coords,scale=1.1,
hexa/.style= {shape=regular polygon,regular polygon
    sides=6,minimum size=1cm, draw,inner sep=0,anchor=south,rotate=30},
hexlattice/.pic={
    \node[hexa] (h1;1) at ({(1-(1+pow(-1,1))*1/4)*sin(60)},{1*0.75}) {}; 
    \node[hexa] (h1;2) at ({(1-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h1;3) at ({(1-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h2;1) at ({(2-(1+pow(-1,1))*1/4)*sin(60)},{1*0.75}) {}; 
    \node[hexa] (h2;2) at ({(2-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h2;3) at ({(2-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h3;2) at ({(3-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
},
hexlattice2/.pic={
    \node[hexa] (h0;3) at ({(0-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h1;1) at ({(1-(1+pow(-1,1))*1/4)*sin(60)},{1*0.75}) {}; 
    \node[hexa] (h1;2) at ({(1-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h1;3) at ({(1-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h1;4) at ({(1-(1+pow(-1,4))*1/4)*sin(60)},{4*0.75}) {}; 
    \node[hexa] (h1;5) at ({(1-(1+pow(-1,5))*1/4)*sin(60)},{5*0.75}) {}; 
    \node[hexa] (h2;1) at ({(2-(1+pow(-1,1))*1/4)*sin(60)},{1*0.75}) {}; 
    \node[hexa] (h2;2) at ({(2-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h2;3) at ({(2-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h2;4) at ({(2-(1+pow(-1,4))*1/4)*sin(60)},{4*0.75}) {}; 
    \node[hexa] (h2;5) at ({(2-(1+pow(-1,5))*1/4)*sin(60)},{5*0.75}) {}; 
    \node[hexa] (h3;1) at ({(3-(1+pow(-1,1))*1/4)*sin(60)},{1*0.75}) {}; 
    \node[hexa] (h3;2) at ({(3-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h3;3) at ({(3-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h3;4) at ({(3-(1+pow(-1,4))*1/4)*sin(60)},{4*0.75}) {}; 
    \node[hexa] (h3;5) at ({(3-(1+pow(-1,5))*1/4)*sin(60)},{5*0.75}) {}; 
    \node[hexa] (h4;2) at ({(4-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h4;3) at ({(4-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h4;4) at ({(4-(1+pow(-1,4))*1/4)*sin(60)},{4*0.75}) {}; 
}]

\begin{scope}[canvas is xz plane at y=0,transform shape]
\pic[scale=1.1] at (5,0) {hexlattice};
\end{scope} 

\begin{scope}[canvas is xz plane at y=0,transform shape]
\pic[scale=0.6] at (0,0) {hexlattice2};
\end{scope} 
\end{tikzpicture}

\end{document}

I need to shift each of the small honeycombs up right in front of their corresponding cubes as below.

enter image description here

But there more I wrestle with the numerical values of those scopes, the less I get closer to what I want!

What is the best workaround to realize such kind of shifts?

1 Answers1

1

This answers the question how to do that at the technical level. It is very easy: add a tikzmark with \rput and then use overlay, remember picture to add the picture.

\documentclass{article}

\usepackage{tikz}
\usepackage{pst-solides3d}    
\usepackage{tikz-3dplot} 
\usetikzlibrary{shapes,3d,tikzmark}

\begin{document}

\psset{viewpoint=10 70 15 rtp2xyz,Decran=10}
\begin{pspicture}[solidmemory](-5,-5)(6,1)
\psSolid[object=parallelepiped,a=6,b=3,c=3,RotZ=30,name=Cube,action=draw](0 0 2)
\multido{\iA=0+1}{8}{%
  \psSolid[object=point,definition=solidgetsommet,args=Cube \iA]}
\psdots*[dotstyle=diamond, fillcolor=red, linecolor = red](0,2)(1,1)(0.5,0.5)(-1,1)(-2,2)(-1.5,3)(1.5,3.5)
\rput(-5,-3.5){\tikzmark{x1}}
\end{pspicture}

\psset{viewpoint=10 60 15 rtp2xyz,Decran=10}
\begin{pspicture}[solidmemory](-7.5,-5)(6,1)
\psSolid[object=parallelepiped,a=10,b=2,c=2.2,RotZ=30,name=Cube,action=draw](0 0 2)
\multido{\iA=0+1}{8}{%
    \psSolid[object=point,definition=solidgetsommet,args=Cube \iA]}
\psdots*[dotstyle=diamond, fillcolor = red, linecolor = red](-2.3,2)(-1.3,1)(-1.8,0.5)(-3,1)(-4.3,2)(-3.8,3)(-0.8,3)
\psdots*[dotstyle=square, fillcolor = blue, linecolor = blue](-0.3,1)(-0.1,1.5)(0.3,2)(0.2,3)(1.5,2)(1,2.7)(0.6,1)(0.8,1.4)(1.7,2.4)(2.3,2.7)(2,1.7)
\rput(-7.5,-3.5){\tikzmark{x2}}
\end{pspicture}

\tdplotsetmaincoords{100}{300}
\begin{tikzpicture}[tdplot_main_coords,scale=1.1,
hexa/.style= {shape=regular polygon,regular polygon
    sides=6,minimum size=1cm, draw,inner sep=0,anchor=south,rotate=30},
hexlattice/.pic={
    \node[hexa] (h1;1) at ({(1-(1+pow(-1,1))*1/4)*sin(60)},{1*0.75}) {}; 
    \node[hexa] (h1;2) at ({(1-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h1;3) at ({(1-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h2;1) at ({(2-(1+pow(-1,1))*1/4)*sin(60)},{1*0.75}) {}; 
    \node[hexa] (h2;2) at ({(2-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h2;3) at ({(2-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h3;2) at ({(3-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
},
hexlattice2/.pic={
    \node[hexa] (h0;3) at ({(0-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h1;1) at ({(1-(1+pow(-1,1))*1/4)*sin(60)},{1*0.75}) {}; 
    \node[hexa] (h1;2) at ({(1-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h1;3) at ({(1-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h1;4) at ({(1-(1+pow(-1,4))*1/4)*sin(60)},{4*0.75}) {}; 
    \node[hexa] (h1;5) at ({(1-(1+pow(-1,5))*1/4)*sin(60)},{5*0.75}) {}; 
    \node[hexa] (h2;1) at ({(2-(1+pow(-1,1))*1/4)*sin(60)},{1*0.75}) {}; 
    \node[hexa] (h2;2) at ({(2-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h2;3) at ({(2-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h2;4) at ({(2-(1+pow(-1,4))*1/4)*sin(60)},{4*0.75}) {}; 
    \node[hexa] (h2;5) at ({(2-(1+pow(-1,5))*1/4)*sin(60)},{5*0.75}) {}; 
    \node[hexa] (h3;1) at ({(3-(1+pow(-1,1))*1/4)*sin(60)},{1*0.75}) {}; 
    \node[hexa] (h3;2) at ({(3-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h3;3) at ({(3-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h3;4) at ({(3-(1+pow(-1,4))*1/4)*sin(60)},{4*0.75}) {}; 
    \node[hexa] (h3;5) at ({(3-(1+pow(-1,5))*1/4)*sin(60)},{5*0.75}) {}; 
    \node[hexa] (h4;2) at ({(4-(1+pow(-1,2))*1/4)*sin(60)},{2*0.75}) {}; 
    \node[hexa] (h4;3) at ({(4-(1+pow(-1,3))*1/4)*sin(60)},{3*0.75}) {}; 
    \node[hexa] (h4;4) at ({(4-(1+pow(-1,4))*1/4)*sin(60)},{4*0.75}) {}; 
},overlay,remember picture]

\begin{scope}[canvas is xz plane at y=0,transform shape]
\pic[scale=1.1] at ([xshift=-5.5cm,yshift=-1.2cm]pic cs:x1) {hexlattice};
\end{scope} 

\begin{scope}[canvas is xz plane at y=0,transform shape]
\pic[scale=0.6] at ([xshift=-9cm,yshift=-1cm]pic cs:x2) {hexlattice2};
\end{scope} 
\end{tikzpicture}

\end{document}

enter image description here

However, I would like to argue that you would be way better off if you just did this with the perspective library of TikZ. Here is a start.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{perspective}
\begin{document}
\begin{tikzpicture}[3d view,%
  perspective,
  pics/hexlattice cell/.style={code={
   \def\pv##1{\pgfkeysvalueof{/tikz/hexlattice/##1}} 
   \tikzset{hexlattice/.cd,#1}
   \draw (tpp cs:x={\pv{x}},y={\pv{y}+\pv{a}*cos(0+\pv{phi})},z={\pv{z}+\pv{a}*sin(0+\pv{phi})})
    foreach \YY in {60,120,...,300}
    {-- (tpp cs:x={\pv{x}},y={\pv{y}+\pv{a}*cos(\YY+\pv{phi})},z={\pv{z}+\pv{a}*sin(\YY+\pv{phi})})}
    -- cycle; }},
  pics/hexlattice/.style={code={
   \def\pv##1{\pgfkeysvalueof{/tikz/hexlattice/##1}} 
   \tikzset{hexlattice/.cd,#1}  
   \ifcase\pv{N}
   \or
    \pic{hexlattice cell={x=\pv{X},y=\pv{Y},z=\pv{Z}}};
   \or
    \path pic{hexlattice cell={x=\pv{X},y=\pv{Y},z=\pv{Z}}}
     foreach \XX in {0,60,...,300}
     {pic{hexlattice cell={x={\pv{X}},
        y={\pv{Y}+2*cos(30)*\pv{a}*cos(30+\XX+\pv{phi})},
        z={\pv{Z}+2*cos(30)*\pv{a}*sin(30+\XX+\pv{phi})}}}};
   \or
    \path pic{hexlattice cell={x=\pv{X},y=\pv{Y},z=\pv{Z}}}
     foreach \XX in {0,60,...,300}
     {pic{hexlattice cell={x={\pv{X}},
        y={\pv{Y}+2*cos(30)*\pv{a}*cos(30+\XX+\pv{phi})},
        z={\pv{Z}+2*cos(30)*\pv{a}*sin(30+\XX+\pv{phi})}}}
     pic{hexlattice cell={x={\pv{X}},
        y={\pv{Y}+2*(1+sin(30))*\pv{a}*cos(\XX+\pv{phi})},
        z={\pv{Z}+2*(1+sin(30))*\pv{a}*sin(\XX+\pv{phi})}}} 
        };
   \or
    \path pic{hexlattice cell={x=\pv{X},y=\pv{Y},z=\pv{Z}}}
     foreach \XX in {0,60,...,300}
     {pic{hexlattice cell={x={\pv{X}},
        y={\pv{Y}+2*cos(30)*\pv{a}*cos(30+\XX+\pv{phi})},
        z={\pv{Z}+2*cos(30)*\pv{a}*sin(30+\XX+\pv{phi})}}}
     pic{hexlattice cell={x={\pv{X}},
        y={\pv{Y}+2*(1+sin(30))*\pv{a}*cos(\XX+\pv{phi})},
        z={\pv{Z}+2*(1+sin(30))*\pv{a}*sin(\XX+\pv{phi})}}}
     pic{hexlattice cell={x={\pv{X}},
        y={\pv{Y}+4*cos(30)*\pv{a}*cos(30+\XX+\pv{phi})},
        z={\pv{Z}+4*cos(30)*\pv{a}*sin(30+\XX+\pv{phi})}}}      
        };
   \fi  
  }},
  hexlattice/.cd,a/.initial=1,x/.initial=0,y/.initial=0,z/.initial=0,
  X/.initial=0,Y/.initial=0,Z/.initial=0,
  N/.initial=1,phi/.initial=0]
 \draw[dashed] (tpp cs:x=10,y=-2,z=4) -- (tpp cs:x=10,y=2,z=4) 
    -- (tpp cs:x=00,y=2,z=4);
 \draw[dashed] (tpp cs:x=10,y=-2,z=0) -- (tpp cs:x=10,y=2,z=0) 
    -- (tpp cs:x=00,y=2,z=0);
 \draw[dashed] (tpp cs:x=10,y=2,z=4) -- (tpp cs:x=10,y=2,z=0);
 \draw (tpp cs:x=0,y=-2,z=0) -- (tpp cs:x=0,y=2,z=0) 
    -- (tpp cs:x=0,y=2,z=4) -- (tpp cs:x=0,y=-2,z=4) -- cycle;
 \draw (tpp cs:x=0,y=-2,z=4) -- (tpp cs:x=10,y=-2,z=4) 
    -- (tpp cs:x=10,y=-2,z=0) -- (tpp cs:x=0,y=-2,z=0) -- cycle;
 \pic{hexlattice={N=4,phi=30,a=0.4,Z=2}};
\end{tikzpicture}
\end{document}

enter image description here