# Create biconcave lens

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}

-
You might be interested in what the package pst-optic provides. –  Werner Jul 11 '12 at 3:05
For future reference, please eliminate packages that are not necessary to reproduce the problem. –  Peter Grill Jul 11 '12 at 4:27
Surely the arcs should be clipped at the intersection with the upper and lower extremities of the lens to give the bi-concave structure you want...I know I'm not helping with code but is that what you want also? –  Leeser Jul 11 '12 at 10:12

Here are two possible choices:

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}
-

Two methods too

A) Without library intersections

We draw and fill a rectangle and then we add the two arcs.

\documentclass[border=3pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\filldraw [red!50,draw=brown, ultra thick] (-1,-0.9) rectangle (1,0.9);

\draw [blue, thick, fill=white] (-1.9,-1.5)
\draw [blue, thick, fill=white] (1.9,1.5)

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

\end{document}

B) With the library intersections but without filling outside

We fill directly the center part. We need to do this to determine the angle defined by the center I of an arc and a point of the arc (here D).

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

\begin{document}
\begin{tikzpicture}
\coordinate (I)  at (1.9,0);
\path [name path=arc1, draw=none](-1.9,-1.5)
\path [name path=arc2, draw=none](1.9,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);

\pgfmathanglebetweenpoints{\pgfpointanchor{I}{center}}{%
\pgfpointanchor{D}{center}}
\let\tmpan\pgfmathresult

\fill[red!50] (A)--(D)
arc[start angle=\tmpan, end angle=360-\tmpan,radius=1.5] -- (B)

\draw [brown, ultra thick] (A) -- (D);
\draw [brown, ultra thick] (B) -- (C) ;
\draw [blue, thick] (-1.9,-1.5) arc[start angle=-90, end angle=90,radius=1.5];
\draw [blue, thick] (1.9,1.5) arc[start angle=90, end angle=270,radius=1.5];

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

-

User interfaces:

\const{Major}{3}% semi major
\const{Minor}{2}% semi minor
\const{Xo}{3.25}% distance from origin to ellipse center

\documentclass[pstricks,border=12pt,nomessages]{standalone}

\def\const#1#2{%
\expandafter\FPeval\csname#1\endcsname{round(#2:17)}%only 17 digits after . is allowed
\pstVerb{/#1 \csname#1\endcsname\space def}%
}

% user defined data
\const{Major}{3}% semi major
\const{Minor}{1.5}% semi minor
\const{Xo}{3.25}% distance from origin to ellipse center

% internal used data
\const{DeltaAx}{Major*cos(Alpha)}
\const{DeltaAy}{Minor*sin(Alpha)}
\const{DeltaBx}{-Major}
\const{DeltaBy}{0}

\psset
{
unit=1.5cm,
linecolor=red,
}

\psscalebox{#1}{
\pnode(!Xo 0){O}
\pnode[!DeltaAx DeltaAy](O){A}
\pnode[!DeltaBx DeltaBy](O){B}
\pnode(0,0){Origin}
\pscustom*[linecolor=yellow,origin={O}]
{
\psline(Origin)(Origin|A)(A)
\psellipticarc(O)(!Major Minor){(A)}{(B)}
}
\psellipticarc[linestyle=dashed,linecolor=gray,origin={O},dimen=middle](O)(!Major Minor){90}{(A)}
\psline(Origin|A)(A)
\psellipticarc[origin={O},dimen=middle](O)(!Major Minor){(A)}{(B)}
}}

\begin{document}

\begin{pspicture}[showgrid=false](-\Xo,-\Minor)(\Xo,\Minor)