3

I apologize if this is a repeat of another question, but I would like to connect the nodes A and B from the left hand side of this picture to the top and bottom of the circle in the right hand side:

enter image description here

So something like this:

enter image description here

Things I have tried:

Using overlay and remember picture

When using these settings, overlay moves the right hand picture to an undesired location and using remember picture by itself to connect the nodes does not work.

Placing both images inside one tikzpicture and using scopes

Unfortunately when placing the right hand side inside the left hand side's tikzpicture environment, the diagram orients itself to the x,y axis (which is actually the x,t plane in the diagram) and hence does not get me the desired output.

I am unsure of how to draw the connecting lines. Here is the code used in the making of the diagram:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{tikz-3dplot}
\usepackage[left=0.00cm, right=0.00cm]{geometry}
\begin{document}
    \tdplotsetmaincoords{72}{170}
    \begin{tikzpicture}[tdplot_main_coords,scale=0.5,xscale=-1]
        \pgfmathsetmacro{\Length}{3}
        \pgfmathsetmacro{\Stretch}{2}
        % \draw[-latex] (0,0,0) -- (\Length,0,0) node[below]{$x$};
        % \draw[-latex] (0,0,0) -- (0,\Length,0) node[left]{$y$};
        % \draw[-latex] (0,0,0) -- (0,0,\Length) node[left]{$z$};
        \draw[black,very thick] plot[smooth,variable=\x,domain=0:720,samples=360] ({\Length*cos(\x)},
        {\x*(\Stretch*\Length/360)},{\Length*sin(\x)});
        \draw (-1.2*\Length,0,-1.2*\Length) coordinate (lbf) -- 
        (1.2*\Length,0,-1.2*\Length) coordinate (lbb) --
        (1.2*\Length,0,1.2*\Length) coordinate (ltb) -- 
        (-1.2*\Length,0,1.2*\Length) coordinate (ltf) -- cycle;
        \foreach \X in {bf,bb,tf}
        {\draw (l\X) -- ++ (0,2*\Stretch*\Length,0) coordinate (m\X);}
        \draw[thick] (mbf) -- (mbb) (mtf) -- (mbf);
        \foreach \X in {bf,bb,tf}
        {\draw[thick] (m\X) -- ++ (0,2*\Stretch*\Length,0) coordinate (r\X);}

        % middle
        \begin{scope}[canvas is zx plane at y=0]
            \node[transform shape,rotate=-90,scale=2,xscale=-1] at (1,0) {Circlular};
            \pgflowlevelsynccm    
            \draw[fill] (0,0) circle (0.2);
        \end{scope}
        \foreach \X in {1,...,5}
        {\ifnum\X=3
        \draw[thin] ($(mbf)!{\X/6}!(mbb)$) -- ++ (0,3*\Stretch*\Length,0);
            \draw[thin] ($(mbf)!{\X/6}!(mtf)$) -- ++ (0,3*\Stretch*\Length,0);
            \else
            \fi}
        \foreach \X [evaluate=\X as \Y using {int(mod(\X,5))}] in {1,...,18}
        {
            \ifnum\Y=0
            \draw[thin] ($(mbf)+(0,\X,0)$) -- ($(mbb)+(0,\X,0)$);
            \draw[thin] ($(mbf)+(0,\X,0)$) -- ($(mtf)+(0,\X,0)$);
            \else
            \fi
        }

        \draw[black,very thick,-latex] plot[smooth,variable=\x,domain=720:1460,samples=360] ({\Length*cos(\x)},
        {\x*(\Stretch*\Length/360)},{\Length*sin(\x)});
        \draw[black,densely dashed] plot[smooth,variable=\x,domain=720:1800,samples=360] 
        ({\Length*cos(\x)},{\x*(\Stretch*\Length/360)},-1.2*\Length);
        \draw[black,densely dashed] plot[smooth,variable=\x,domain=720:1800,samples=360] 
        (-1.2*\Length,{\x*(\Stretch*\Length/360)},{\Length*sin(\x)});
        % right
        \foreach \X in {bf,bb,tf}
            {\draw[very thick] (r\X) -- ++ (0,\Stretch*\Length,0);}
        \draw[very thick,fill=white,fill opacity=0.5] (rbf) -- (rbb) (rtf) -- (rbf);
        \draw[thick,densely dashed,-latex] plot[smooth,variable=\x,domain=0:-360] 
        ({\Length*cos(\x)},0,{-\Length*sin(\x)});

        \path (mbb) node[right=3pt,font=\Large\sffamily] {Cosine};
        \path (rtf) node[above left=3pt,font=\Large\sffamily] {Sine};
        \draw[-latex] (-3.6,0,-3.6) -- (-3.6,37,-3.6) node[left,font=\Large] {$t$};
        \draw[-latex] (3.6,0,-3.6)-- (5,0,-3.6) node [right,font=\Large] {$x$};
        \draw[-latex] (-3.6,0,3.6)-- (-3.6,0,5) node [above,font=\Large] {$y$};

        % NODES I WOULD LIKE TO CONNECT THE SECOND PICTURE TO:

        \node at (0,0,3) (A) {};
        \node at (0,0,-3) (B) {};
    \end{tikzpicture}
    \tdplotsetmaincoords{0}{0}
    \begin{tikzpicture}[remember picture]
        \draw[-latex] (-5,0) -- (5,0) node [right] {$x$};
        \draw[-latex] (0,-5) -- (0,5) node [above] {$y$};
        \draw[densely dashed] (0,0) circle (4);
        \draw[ultra thick,-latex] (0,0) -- (60:4) node[above right] {$E$};
        \draw[-latex,thick] (0,0) -- (2,0) node[below] {$x$};
        \draw[-latex,thick] (0,0) -- (0,3.46410615) node[left] {$y$};
        \draw[densely dashed] (2,0) -- (60:4) -- (0,3.46410615);
        \fill (0,0) circle (0.1);
        \draw[-latex] (60:4) -- (70:4);
    \end{tikzpicture}
\end{document}
0

1 Answer 1

4

There are two aspects in this question.

  1. How to connect points from different tikzpictures. This is well-known: add remember picture to the keys and then use a separate picture with remember picture,overlay to connect coordinates.
  2. Then it is probably desirable to have the lines being tangents to the circles. Some exact solutions are known. I use an analytical formula used here but add slight corrections by hand because the left circle is a projection of a circle and thus not an exact circle.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{tikz-3dplot}
\usepackage[left=0.00cm, right=0.00cm]{geometry}
\begin{document}
    \tdplotsetmaincoords{72}{170}
    \begin{tikzpicture}[tdplot_main_coords,scale=0.5,xscale=-1,remember picture]
        \pgfmathsetmacro{\Length}{3}
        \pgfmathsetmacro{\Stretch}{2}
        % \draw[-latex] (0,0,0) -- (\Length,0,0) node[below]{$x$};
        % \draw[-latex] (0,0,0) -- (0,\Length,0) node[left]{$y$};
        % \draw[-latex] (0,0,0) -- (0,0,\Length) node[left]{$z$};
        \draw[black,very thick] plot[smooth,variable=\x,domain=0:720,samples=360] ({\Length*cos(\x)},
        {\x*(\Stretch*\Length/360)},{\Length*sin(\x)});
        \draw (-1.2*\Length,0,-1.2*\Length) coordinate (lbf) -- 
        (1.2*\Length,0,-1.2*\Length) coordinate (lbb) --
        (1.2*\Length,0,1.2*\Length) coordinate (ltb) -- 
        (-1.2*\Length,0,1.2*\Length) coordinate (ltf) -- cycle;
        \foreach \X in {bf,bb,tf}
        {\draw (l\X) -- ++ (0,2*\Stretch*\Length,0) coordinate (m\X);}
        \draw[thick] (mbf) -- (mbb) (mtf) -- (mbf);
        \foreach \X in {bf,bb,tf}
        {\draw[thick] (m\X) -- ++ (0,2*\Stretch*\Length,0) coordinate (r\X);}

        % middle
        \begin{scope}[canvas is zx plane at y=0]
            \node[transform shape,rotate=-90,scale=2,xscale=-1] at (1,0) {Circlular};
            \pgflowlevelsynccm    
            \draw[fill] (0,0) circle (0.2);
        \end{scope}
        \foreach \X in {1,...,5}
        {\ifnum\X=3
        \draw[thin] ($(mbf)!{\X/6}!(mbb)$) -- ++ (0,3*\Stretch*\Length,0);
            \draw[thin] ($(mbf)!{\X/6}!(mtf)$) -- ++ (0,3*\Stretch*\Length,0);
            \else
            \fi}
        \foreach \X [evaluate=\X as \Y using {int(mod(\X,5))}] in {1,...,18}
        {
            \ifnum\Y=0
            \draw[thin] ($(mbf)+(0,\X,0)$) -- ($(mbb)+(0,\X,0)$);
            \draw[thin] ($(mbf)+(0,\X,0)$) -- ($(mtf)+(0,\X,0)$);
            \else
            \fi
        }

        \draw[black,very thick,-latex] plot[smooth,variable=\x,domain=720:1460,samples=360] ({\Length*cos(\x)},
        {\x*(\Stretch*\Length/360)},{\Length*sin(\x)});
        \draw[black,densely dashed] plot[smooth,variable=\x,domain=720:1800,samples=360] 
        ({\Length*cos(\x)},{\x*(\Stretch*\Length/360)},-1.2*\Length);
        \draw[black,densely dashed] plot[smooth,variable=\x,domain=720:1800,samples=360] 
        (-1.2*\Length,{\x*(\Stretch*\Length/360)},{\Length*sin(\x)});
        % right
        \foreach \X in {bf,bb,tf}
            {\draw[very thick] (r\X) -- ++ (0,\Stretch*\Length,0);}
        \draw[very thick,fill=white,fill opacity=0.5] (rbf) -- (rbb) (rtf) -- (rbf);
        \draw[thick,densely dashed,-latex] 
        plot[smooth,variable=\x,domain=0:-360] 
        ({\Length*cos(\x)},0,{-\Length*sin(\x)});
        \path (0,0,0) coordinate (M) (\Length,0,0) coordinate (c0);
        \path (mbb) node[right=3pt,font=\Large\sffamily] {Cosine};
        \path (rtf) node[above left=3pt,font=\Large\sffamily] {Sine};
        \draw[-latex] (-3.6,0,-3.6) -- (-3.6,37,-3.6) node[left,font=\Large] {$t$};
        \draw[-latex] (3.6,0,-3.6)-- (5,0,-3.6) node [right,font=\Large] {$x$};
        \draw[-latex] (-3.6,0,3.6)-- (-3.6,0,5) node [above,font=\Large] {$y$};

        % NODES I WOULD LIKE TO CONNECT THE SECOND PICTURE TO:

        \node at (0,0,3) (A) {};
        \node at (0,0,-3) (B) {};
    \end{tikzpicture}
    \tdplotsetmaincoords{0}{0}
    \begin{tikzpicture}[remember picture]
        \draw[-latex] (-5,0) -- (5,0) node [right] {$x$};
        \draw[-latex] (0,-5) -- (0,5) node [above] {$y$};
        \draw[densely dashed] (0,0) coordinate (N) circle (4);
        \draw[ultra thick,-latex] (0,0) -- (60:4) node[above right] {$E$};
        \draw[-latex,thick] (0,0) -- (2,0) node[below] {$x$};
        \draw[-latex,thick] (0,0) -- (0,3.46410615) node[left] {$y$};
        \draw[densely dashed] (2,0) -- (60:4) -- (0,3.46410615);
        \fill (0,0) circle (0.1);
        \draw[-latex] (60:4) -- (70:4);
    \end{tikzpicture}
    \begin{tikzpicture}[overlay,remember picture]
        \draw let \p1=($(N)-(M)$),\p2=($(M)-(c0)$),
        \n1={atan2(\y1,\x1)},\n2={veclen(\y1,\x1)},
        \n3={veclen(\x2,\y2)},\n4={atan2(4cm-\n3,\n2)}
    in
        %\pgfextra{\typeout{\n1,\n4}}
        ($(M)+(-90-\n4+\n1:0.97*\n3)$) -- ($(N)+(-90-\n4+\n1:4cm)$)
        ($(M)+(90+\n4+\n1:0.98*\n3)$) -- ($(N)+(90+\n4+\n1:4cm)$);
\end{tikzpicture}
\end{document}

enter image description here

It is good that you made me explain the code. There was a bug and the analytic formula works, one only has to account for the fact that the left circle is a tiny bit distorted because of the projection.

Here come the explanations. The whole thing is calc syntax and we make use of the fact that the slope of the tangents are given by the slope of the line connecting the centers plus something coming from the fact that the radii are different. Once we know the slope, the points are uniquely determined.

 \draw let \p1=($(N)-(M)$), % \p1 is the vector from M to N, i.e. the difference
 % between the centers of the circles
 \p2=($(M)-(c0)$), % \p1 is the vector from M to c0
 \n1={atan2(\y1,\x1)}, % \n1 is the slope of the vector from M to N
 \n2={veclen(\y1,\x1)}, % \n2 is the distance of M and N
 \n3={veclen(\x2,\y2)}, % \n3 is the length of the vector from M to c0,
 % i.e. the radius of the left circle 
 \n4={atan2(4cm-\n3,\n2)} % \n4 is the additional slope the tangent has because
 % the radii are different
    in
        ($(M)+(-90-\n4+\n1:0.97*\n3)$) -- ($(N)+(-90-\n4+\n1:4cm)$)% point on the left circle in the form 
        % center + shift in polar coordinates (angle:radius)
        ($(M)+(90+\n4+\n1:0.98*\n3)$) -- ($(N)+(90+\n4+\n1:4cm)$);
        % same for the right point. 0.97 and 0.97 are needed to 
        % because the left circle is a projection, i.e. not an exact circle  
2
  • Could you please let me know what everything inside the last tikzpicture section means or at least where they are in the manual, I do not know what they mean
    – sab hoque
    Jan 10, 2019 at 8:49
  • 1
    @sabhoque Done. Thanks! This helped me to fix a bug and now the analytical determination works very well, no more adjustments by hand. (There was a conversion factor in the old example because there the radii were specified without units but was not needed here, and spoiled tie formula.)
    – user121799
    Jan 10, 2019 at 15:23

You must log in to answer this question.

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