[Tex/LaTex] Create biconcave lens

tikz-pgf

I have been trying for hours.. can anyone help me? I can't fill with color the "shape" that is the lens.

\documentclass[border=12pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}

\begin{tikzpicture}[scale=1]

\begin{scope}[>=latex]
\draw [->] (-3,0) -- (3,0);
\draw [->] (0,-1.25) -- (0,1.5);
\end{scope}
\definecolor{lensBlue}{RGB}{217,232,250}



\path [name path=arc1](-1.9,-1.5) arc[start angle=-90, end angle=90,radius=1.5];
\path [name path=arc2](1.9,1.5) arc[start angle=90, end angle=270,radius=1.5];
\path [name path=rect](-0.9,-0.9) rectangle (0.9,0.9);


\path [name intersections={of = arc1 and rect}];
\coordinate (A)  at (intersection-1);
\coordinate (B)  at (intersection-2);

\path [name intersections={of = arc2 and rect}];
\coordinate (C)  at (intersection-1);
\coordinate (D)  at (intersection-2);

\draw (A) -- (D);
\draw (B) -- (C) ;

\draw (-1.9,-1.5) arc[start angle=-90, end angle=90,radius=1.5];
\draw (1.9,1.5) arc[start angle=90, end angle=270,radius=1.5];


\end{tikzpicture}

\end{document}

enter image description here

Best Answer

Here are two possible choices:

enter image description here

In the first case I used fill=white to white out the pink fill in in arc sections. But if you want that filled in you can do as in the second case. The drawing of the aixs was moved to the end so that it is on top. You could also achieve the same effect with the backgrounds library using on background layer.

Code:

\documentclass[border=3pt]{standalone}

\usepackage{tikz} %pgf-tikz pakcage
\usetikzlibrary{intersections}

\definecolor{lensBlue}{RGB}{217,232,250}

\begin{document}
\begin{tikzpicture}

\path [name path=arc1, draw=none](-1.9,-1.5) arc[start angle=-90, end angle=90,radius=1.5];
\path [name path=arc2, draw=none](1.9,1.5) arc[start angle=90, end angle=270,radius=1.5];
\path [name path=rect, draw=none](-0.9,-0.9) rectangle (0.9,0.9);

\path [name intersections={of = arc1 and rect}];
\coordinate (A)  at (intersection-1);
\coordinate (B)  at (intersection-2);

\path [name intersections={of = arc2 and rect}];
\coordinate (C)  at (intersection-1);
\coordinate (D)  at (intersection-2);

\draw [brown, ultra thick] (A) -- (D);
\draw [brown, ultra thick] (B) -- (C) ;

\fill [red!50] (A) -- (D) -- (C) -- (B) -- cycle;

\draw [blue, thick, fill=white] (-1.9,-1.5) arc[start angle=-90, end angle=90,radius=1.5];
\draw [blue, thick, fill=white] (1.9,1.5) arc[start angle=90, end angle=270,radius=1.5];

% axis
\begin{scope}[>=latex]
    \draw [->] (-3,0) -- (3,0);
    \draw [->] (0,-1.25) -- (0,1.5);
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}

\path [name path=arc1, draw=none](-1.9,-1.5) arc[start angle=-90, end angle=90,radius=1.5];
\path [name path=arc2, draw=none](1.9,1.5) arc[start angle=90, end angle=270,radius=1.5];
\path [name path=rect, draw=none](-0.9,-0.9) rectangle (0.9,0.9);

\path [name intersections={of = arc1 and rect}];
\coordinate (A)  at (intersection-1);
\coordinate (B)  at (intersection-2);

\path [name intersections={of = arc2 and rect}];
\coordinate (C)  at (intersection-1);
\coordinate (D)  at (intersection-2);

\draw [brown, ultra thick] (A) -- (D);
\draw [brown, ultra thick] (B) -- (C) ;

\fill [red!50] (A) -- (D) -- (C) -- (B) -- cycle;

\draw [blue, thick, fill=yellow!50] (-1.9,-1.5) arc[start angle=-90, end angle=90,radius=1.5];
\draw [blue, thick, fill=yellow!50] (1.9,1.5) arc[start angle=90, end angle=270,radius=1.5];

% axis
\begin{scope}[>=latex]
    \draw [->] (-3,0) -- (3,0);
    \draw [->] (0,-1.25) -- (0,1.5);
\end{scope}
\end{tikzpicture}

\end{document}