我怎样才能用 制作凸透镜TikZ
?
我尝试使用弧线,但看起来不正确。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\xr}{0.35}
\pgfmathsetmacro{\yr}{2}
\draw (0, 0) coordinate (O) arc[x radius = \xr cm, y radius = \yr cm,
start angle = 90, end angle = 270];
\draw (O) arc[x radius = \xr cm, y radius = \yr cm,
start angle = 90, end angle = -90];
\end{tikzpicture}
\end{document}
我希望圆弧在尖角处相交,而不是圆角。
答案1
以下是一个建议:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\lensRadius}{2}
\pgfmathsetmacro{\lensHeight}{1}
\pgfmathsetmacro{\startAngle}{asin(\lensHeight/\lensRadius)}
\draw (0,\lensHeight) arc[start angle=180-\startAngle,delta angle=2*\startAngle,radius=\lensRadius];
\draw (0,\lensHeight) arc[start angle=\startAngle,delta angle=-2*\startAngle,radius=\lensRadius];
\end{tikzpicture}
\end{document}
稍作修改,以便填充并获得更好的线条末端:
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\lensRadius}{2}
\pgfmathsetmacro{\lensHeight}{1}
\pgfmathsetmacro{\startAngle}{asin(\lensHeight/\lensRadius)}
\draw [fill=blue!15] (0,\lensHeight)
arc[start angle=180-\startAngle,delta angle=2*\startAngle,radius=\lensRadius]
arc[start angle=-\startAngle,delta angle=2*\startAngle,radius=\lensRadius]
-- cycle; % to get a better line end
\end{tikzpicture}
\end{document}
答案2
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[line join=round,fill=blue!15] (0,0) arc (-30:30:2 and 3) arc (150:210:2 and 3) ;
\end{tikzpicture}
\end{document}
答案3
从我之前的 TiKz 学习来看:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[fill=orange]
([shift={(-40:1cm)}]0,0) arc (-40:40:1cm);
\draw[fill=orange,rotate=180]
([shift={(-40:1cm)}]-1.535,0) arc (-40:40:1cm);
\end{tikzpicture}
\end{document}
答案4
只需画两条线:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[fill=blue!15] (0,2) to[in=130,out=230] (0,-2) to[in=-50,out=50] (0,2) -- cycle;
\end{tikzpicture}
\end{document}