Tikz 中的双凹透镜

Tikz 中的双凹透镜

大家好,圣诞快乐(虽然有点晚了哈哈)。我想画一个像下面这样的双凹透镜,但我真的做不到。

在此处输入图片描述

这是我设法写出来的,但这不是我希望得到的结果。

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[scale=0.9]
\pgfmathsetmacro{\lensRadius}{2.6}
\pgfmathsetmacro{\lensHeight}{1.8}
\pgfmathsetmacro{\startAngle}{-asin(\lensHeight/\lensRadius)}

\draw [fill=lightgray!50, very thick]  (0,\lensHeight)
arc[start angle=-\startAngle,delta 
angle=2*\startAngle,radius=\lensRadius]
--++ (0:2)
arc[start angle=-\startAngle,delta angle=2*\startAngle,radius=- 
\lensRadius]
-- cycle;
\end{tikzpicture}
\end{document}

答案1

这将绘制此类透镜。它允许您选择不同的半径,但当然您也可以将它们设置为相等。焦点的位置是通过透镜制造商方程。使用 pgf 键代替宏。参数包括高度h、厚度d、折射率n和半径R1R2。参数alpha仅表示虚线青色线的斜率。

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
 \begin{tikzpicture}[bullet/.style={circle,black,fill,inner sep=1.8pt},
   every label/.append style={black},
   declare function={lensf(\n,\d,\Rone,\Rtwo)=1/(
   (\n-1)*(1/\Rone-1/\Rtwo+(\n-1)*\d/(\n*\Rone*\Rtwo)));
   startangle(\h,\r)=asin(\h/\r);},
   lens/.cd,n/.initial=1.7,R1/.initial=3.6,R2/.initial=-3.9,d/.initial=0.6,
   h/.initial=1.8,alpha/.initial=20]
  %short cut 
  \def\pv#1{\pgfkeysvalueof{/tikz/lens/#1}} 

  \draw [fill=lightgray!50, very thick]  
    ({-\pv{d}/2-cos(90-startangle(\pv{h},\pv{R1}))},\pv{h})
    arc[start angle={startangle(\pv{h},\pv{R1})},delta 
    angle={-2*startangle(\pv{h},\pv{R1})},radius=\pv{R1}]
    --++ ({\pv{d}+cos(90-startangle(\pv{h},\pv{R1}))+cos(90+startangle(\pv{h},\pv{R2}))},0)
    arc[start angle={-startangle(\pv{h},\pv{R2})},delta 
    angle={2*startangle(\pv{h},\pv{R2})},radius=\pv{R2}]  
    -- cycle;
   \draw[very thick,dashed] (0,-1.2*\pv{h}) --  (0,1.2*\pv{h});
   \draw[very thick] (-1.2*\pv{R1}-\pv{d}/2,0) -- (-1.2*\pv{R2}+\pv{d}/2,0);
   \draw[cyan,dashed,thick] ({-\pv{d}/2-\pv{R1}},0)   
    node[bullet,label=below:$C_1$]{}
   -- node[sloped,above]{$R_1$} ++ (\pv{alpha}:\pv{R1});
   \path ({-lensf(\pv{n},\pv{d},\pv{R1},\pv{R2})},0) 
    node[bullet,label=below:$F_2$]{};
   \draw[cyan,dashed,thick] ({\pv{d}/2-1*\pv{R2}},0)    
    node[bullet,label=above:$C_2$]{}
   -- node[sloped,below]{$R_2$} ++ (\pv{alpha}:\pv{R2});
   \path ({lensf(\pv{n},\pv{d},-1*\pv{R2},-1*\pv{R1})},0) 
    node[bullet,label=above:$F_1$]{};
 \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容