3

I am currently trying to draw the following picture in TikZ:

Picture

Yet, I have trouble drawing the two cones such that they show in that particular direction.

Thanks to @Schrödinger's cat. I finished the picture based on his solution with the cones (with german text):

\documentclass[tikz,border=3mm]{standalone}
\newcounter{iloop}
\usetikzlibrary{arrows}
\usepackage{tikz-3dplot}
\tikzset{pics/ycone/.style={code={
\tikzset{cone/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/cone/##1}}
\path (0,0,0) coordinate (-tip);
\begin{scope}[canvas is xz plane at y=\pv{h}/1cm]
 \path[/tikz/cone/base] (0,0) coordinate(-base) circle[radius=\pv{r}];
 \setcounter{iloop}{0}%
 \pgfmathsetmacro{\myangleA}{0}%
 \pgfmathsetmacro{\myangleB}{0}%
 \pgfmathsetmacro{\myvisangleA}{-180}%
 \pgfmathsetmacro{\myvisangleB}{180}%
 \loop%
 \path (\number\value{iloop}:\pv{r}) coordinate (taux);
 \pgfmathanglebetweenlines%
   {\pgfpointanchor{-tip}{center}}{\pgfpointanchor{-base}{center}}
   {\pgfpointanchor{-tip}{center}}{\pgfpointanchor{taux}{center}}%  
 \edef\testangle{\pgfmathresult}%
 \pgfmathsetmacro\testangle{sin(\testangle)}
 \ifdim\testangle pt<\myangleA pt\relax%
  \pgfmathsetmacro{\myangleA}{\testangle}%
  \pgfmathsetmacro{\myvisangleA}{\value{iloop}}%
 \fi
 \ifdim\testangle pt>\myangleB pt\relax%
  \pgfmathsetmacro{\myangleB}{\testangle}%
  \pgfmathsetmacro{\myvisangleB}{\value{iloop}}%
 \fi
 \stepcounter{iloop}\ifnum\value{iloop}<361\repeat
 \ifdim\myvisangleB pt>180 pt
  \pgfmathsetmacro{\myvisangleB}{\myvisangleB-360}
 \fi
  \path[/tikz/cone/mantle] (\myvisangleA:\pv{r})
   arc(\myvisangleA:\myvisangleB:\pv{r})
   -- (-tip) -- cycle;
\end{scope}
}},cone/.cd,base/.style={draw,fill=green!60!gray,fill opacity=0.4},
mantle/.style={draw,fill=green!30!black,fill opacity=0.4},
r/.initial=1cm,h/.initial=2cm}
\begin{document}
\tdplotsetmaincoords{60}{165}
\begin{tikzpicture}[tdplot_main_coords,line cap=round]
 \draw[ultra thick, red] (.3,-2,.5) -- (0,0,0);

 \fill[blue!20,opacity=.8] (-1,0,-1) -- (1,0,-1) -- (1,0,.5) -- (-1,0,.5) -- cycle;
 \fill[blue!30,opacity=.8] (-1,-0.5,.5) -- (1,-0.5,.5) -- (1,0,.5) -- (-1,0,.5) -- cycle;
 \fill[blue!50,opacity=.8] (1,-0.5,.5) -- (1,0,.5) -- (1,0,-1) -- (1,-0.5,-1) -- cycle;

  \draw[ultra thick, red,shorten >=1mm] (0,0,0) -- (.5,9.5,0);
 \tdplotsetrotatedcoords{3}{00}{0}
 \path[tdplot_rotated_coords] 
    pic{ycone={r=1.5cm,h=6cm}};
 \tdplotsetrotatedcoords{-5}{00}{0}
 \path[tdplot_rotated_coords] 
    pic{ycone={r=1.5cm,h=9cm}};
  \draw[ultra thick, red,-*] (.33,6.5,0) -- (.5,9.5,0);

  \draw[thick, green] (0,0,0) -- (1.8,9.5,0);
  \draw[thick, green,-stealth'] (1.8,9.5,0) -- (2.1,9.5,0);
  \draw[thick, green,-stealth'] (1.8,9.5,0) -- (1.5,9.5,0);
  \draw[thick, green,-stealth'] (1.8,9.5,0) -- (1.8,9.5,-.3);
  \draw[thick, green,-stealth'] (1.8,9.5,0) -- (1.8,9.5,.3);

  \draw[thick, green] (0,0,0) -- (-1.05,9.5,0);
  \draw[thick, green,-stealth'] (-1.05,9.5,0) -- (-1.35,9.5,0);
  \draw[thick, green,-stealth'] (-1.05,9.5,0) -- (-.75,9.5,0);
  \draw[thick, green,-stealth'] (-1.05,9.5,0) -- (-1.05,9.5,.3);
  \draw[thick, green,-stealth'] (-1.05,9.5,0) -- (-1.05,9.5,-.3);

 \draw[dashdotted, gray!50!black] (0,0,0) -- (.38,7.5,1);
 \draw[dashdotted, gray!50!black] (0,0,0) -- (.38,7.5,0);
 \draw[dashdotted, gray!50!black] (0,0,0) -- (.38,7.5,-1);

  % Annotation
  \path[-stealth',black,shorten >=1mm] (-.3,-1.5,1) edge node[anchor=west,pos=0] {Laserstrahl} (.3,-1.5,.5);

  \path[-stealth',black,shorten >=1mm] (-2,0,.5)  edge node[anchor=west,pos=0] {Kristall} (-1,0,0) ;

  \path[-stealth',black,shorten >=1mm] (-2,2.3,.5)  edge node[anchor=west,pos=0,text width=2cm,align=center] {Vertikal polarisierte Photonen} (-1,2.3,0) ;

  \path[-stealth',black,shorten >=1mm] (2,3,-.5)  edge node[anchor=east,pos=0,text width=2cm,align=center] {Horizontal polarisierte Photonen} (1,4,-.5) ;

  \path[-stealth',black,shorten >=1mm] (.5,10.5,-1)  edge node[anchor=north,pos=0,text width=2cm,align=center] {verschränkte Photonen} (-1.05,9.5,0)
        edge (1.8,9.5,0) ;

 \end{tikzpicture}
\end{document}

final version of picture

1
  • 1
    It would be great if you could show us what you have tried. Posting a minimal working example that indicates what you are trying to do makes it easier for people to understand what you want. It also makes it easier for people to help you, since they have some code to start from, and hence much more likely that some one will try to help you.
    – user30471
    Feb 1, 2020 at 0:14

1 Answer 1

5

This draws such cones.

\documentclass[tikz,border=3mm]{standalone}
\newcounter{iloop}
\usepackage{tikz-3dplot}
\tikzset{pics/ycone/.style={code={
\tikzset{cone/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/cone/##1}}
\path (0,0,0) coordinate (-tip);
\begin{scope}[canvas is xz plane at y=\pv{h}/1cm]
 \path[/tikz/cone/base] (0,0) coordinate(-base) circle[radius=\pv{r}];
 \setcounter{iloop}{0}%
 \pgfmathsetmacro{\myangleA}{0}%
 \pgfmathsetmacro{\myangleB}{0}%
 \pgfmathsetmacro{\myvisangleA}{-180}%
 \pgfmathsetmacro{\myvisangleB}{180}%
 \loop%
 \path (\number\value{iloop}:\pv{r}) coordinate (taux);
 \pgfmathanglebetweenlines%
   {\pgfpointanchor{-tip}{center}}{\pgfpointanchor{-base}{center}}
   {\pgfpointanchor{-tip}{center}}{\pgfpointanchor{taux}{center}}%  
 \edef\testangle{\pgfmathresult}%
 \pgfmathsetmacro\testangle{sin(\testangle)}
 \ifdim\testangle pt<\myangleA pt\relax%
  \pgfmathsetmacro{\myangleA}{\testangle}%
  \pgfmathsetmacro{\myvisangleA}{\value{iloop}}%
 \fi
 \ifdim\testangle pt>\myangleB pt\relax%
  \pgfmathsetmacro{\myangleB}{\testangle}%
  \pgfmathsetmacro{\myvisangleB}{\value{iloop}}%
 \fi
 \stepcounter{iloop}\ifnum\value{iloop}<361\repeat
 \ifdim\myvisangleB pt>180 pt
  \pgfmathsetmacro{\myvisangleB}{\myvisangleB-360}
 \fi
  \path[/tikz/cone/mantle] (\myvisangleA:\pv{r})
   arc(\myvisangleA:\myvisangleB:\pv{r})
   -- (-tip) -- cycle;
\end{scope}
}},cone/.cd,base/.style={draw,fill=green!60!black,fill opacity=0.4},
mantle/.style={draw,fill=green!30!gray,fill opacity=0.4},
r/.initial=1cm,h/.initial=2cm}
\begin{document}
\tdplotsetmaincoords{60}{165}
\begin{tikzpicture}[tdplot_main_coords,line cap=round]
 \fill[blue!20] (-1,0,-1) -- (1,0,-1) -- (1,0,1) -- (-1,0,1) -- cycle;
 \fill[blue!30] (-1,-0.5,1) -- (1,-0.5,1) -- (1,0,1) -- (-1,0,1) -- cycle;
 \fill[blue!50] (1,-0.5,1) -- (1,0,1) -- (1,0,-1) -- (1,-0.5,-1) -- cycle;
 \tdplotsetrotatedcoords{3}{00}{0}
 \path[tdplot_rotated_coords] 
    pic{ycone={r=1.5cm,h=6cm}};
 \tdplotsetrotatedcoords{-5}{00}{0}
 \path[tdplot_rotated_coords] 
    pic{ycone={r=1.5cm,h=9cm}};
 \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 .