%%%% $Id: pst-optic.tex 1019 2024-10-28 07:59:50Z herbert $
%% This is file `pst-optic.tex',
%% 
%% IMPORTANT NOTICE:
%% 
%% Package `pst-optic.tex'
%%
%% Manuel Luque <Mluque5130@aol.com> (France)
%% Herbert Voss <hvoss@tug.org> (Germany)
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `pst-optic' is a PSTricks package to define lenses and mirrors
%%
\csname PSTopticLoaded\endcsname
\let\PSTopticLoaded\endinput
% Requires PSTricks, pst-node, pst-plot, pst-grad, pst-3d, 
% pst-math, pst-xkey, multido packages
\ifx\PSTricksLoaded\endinput\else  \input pstricks.tex\fi
\ifx\PSTnodesLoaded\endinput\else  \input pst-node.tex\fi
\ifx\PSTplotLoaded\endinput\else   \input pst-plot.tex\fi  % parametric-plot
\ifx\PSTthreeDLoaded\endinput\else \input pst-3d.tex\fi	% symplan
\ifx\PSTGradLoaded\endinput\else   \input pst-grad.tex\fi
\ifx\PSTmathLoaded\endinput\else   \input pst-math.tex\fi
\ifx\PSTMultidoLoaded\endinput\else\input multido.tex\fi
\ifx\PSTXKeyLoaded\endinput\else   \input pst-xkey\fi
%
\def\fileversion{1.05}
\def\filedate{2024/10/28}
\message{`PST-Optic' v\fileversion, \filedate\space (Manuel Luque and Herbert Voss)}
%
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
\pst@addfams{pst-optic}
\SpecialCoor
%
%%%%%%%%%%%%%%%%%% Macrolist %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% \def\Arrows[#1](#2)(#3)
%% \def\psOutLine[#1](#2)(#3)#4
%% \def\psBeforeLine[#1](#2)(#3)#4
%% \def\ABinterCD(#1)(#2)(#3)(#4)#5
%% \def\Parallel[#1](#2)(#3)(#4)#5
%% \def\arrowLine[#1](#2)(#3)#4
%% \def\nodeBetween(#1)(#2)#3
%% \def\rotateNode(#1)#2
%% \def\rotateTriangle(#1)(#2)(#3)#4
%% \def\rotateFrame(#1)(#2)(#3)(#4)#5
%% \def\lensSPH[#1]
%% \def\lensSPHRay[#1](#2)(#3)#4#5#6
%% \def\ABinterSPHLens(#1)(#2)(#3)#4
%% \def\lens[#1]
%% \def\pslensDVG
%% \def\pslensDVG@i#1#2
%% \def\pslensDVG@ii
%% \def\pslensCVG
%% \def\pslensCVG@ii
%% \def\lensCVG
%% \def\lensDVG
%% \def\Transform
%% \def\rayInterLens(#1)(#2)#3#4
%% \def\mirrorCVGRay[#1](#2)(#3)#4
%% \def\mirrorCVG[#1]
%% \def\mirrorDVG[#1]
%% \def\mirrorDVGRay[#1](#2)(#3)#4
%% \def\beamLight[#1]
%% \def\mirrorTwo
%% \def\telescope[#1]
%% \def\planMirrorRay(#1)(#2)(#3)#4
%% \def\symPlan(#1)(#2)
%% \def\refractionRay[#1](#2)(#3)(#4)(#5)#6#7#8
%% \def\reflectionRay[#1](#2)(#3)#4
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ---------------- the if's -----------------
%
\define@boolkey[psset]{pst-optic}[Pst@]{lensTwo}[false]{} % is a second lens present?
\define@boolkey[psset]{pst-optic}[Pst@]{lensGlass}[true]{}% draw a _real_ lens? 
\define@boolkey[psset]{pst-optic}[Pst@]{onlyrays}[true]{}% draw only the rays? 
\define@boolkey[psset]{pst-optic}[Pst@]{drawing}[true]{}  % draw the nodes and rays?
\define@boolkey[psset]{pst-optic}[Pst@]{rightRay}[false]{}% a ray on the right side?
%
\psset[pst-optic]{lensGlass,drawing,lensTwo,rightRay,onlyrays=false}
%
% ------- the global definitions for the pspicture frame ------
%
\define@key[psset]{pst-optic}{xLeft}[-7.5]{\def\psk@optic@xLeft{#1}}
\define@key[psset]{pst-optic}{xRight}[7.5]{\def\psk@optic@xRight{#1}}
\define@key[psset]{pst-optic}{yBottom}[-3.0]{\def\psk@optic@yBottom{#1}}
\define@key[psset]{pst-optic}{yTop}[3.0]{\def\psk@optic@yTop{#1}}
\psset[pst-optic]{xLeft=-7.5,xRight=7.5,yBottom=-3.0,yTop=3.0}
%
% ---------------- the lenses -----------------
%
\define@key[psset]{pst-optic}{lensType}[CVG]{\def\psk@optic@lensType{#1}}% CVG|DVG|PCVG|PDVG
\define@key[psset]{pst-optic}{lensColor}[lightgray]{\def\psk@optic@lensColor{#1}}
\define@key[psset]{pst-optic}{lensWidth}[0.5]{\def\psk@optic@lensWidth{#1}}%		the thichness of the lens
\define@key[psset]{pst-optic}{lensDepth}[1]{\def\psk@optic@lensDepth{#1}}
\define@key[psset]{pst-optic}{lensHeight}[5]{\def\psk@optic@lensHeight{#1}}%	the TOTAL height of the lens
\define@key[psset]{pst-optic}{lensScale}[1]{\def\psk@optic@lensScale{#1}}%		more or less obsolete
\define@key[psset]{pst-optic}{lensArrowSize}[0.2]{\def\psk@optic@lensArrowSize{#1}}%	for the AB,... Arrows
\define@key[psset]{pst-optic}{lensArrowInset}[0.5]{\def\psk@optic@lensArrowInset{#1}}
\def\lensTypeCVG{CVG}
\def\lensTypeDVG{DVG}
\def\lensTypePCVG{PCVG}
\def\lensTypePDVG{PDVG}
\psset[pst-optic]{lensType=CVG,lensColor=lightgray,lensWidth=0.5,lensDepth=1,
  lensHeight=5,lensScale=1,lensArrowSize=0.2,lensArrowInset=0.5}
%
% ---------------- the mirrors -----------------
%
\define@key[psset]{pst-optic}{mirrorType}[CVG]{\def\psk@optic@mirrorType{#1}}% PLAN|PARAbolic|SPHerical
\define@key[psset]{pst-optic}{mirrorDepth}[1]{\def\psk@optic@mirrorDepth{#1}}
\define@key[psset]{pst-optic}{mirrorHeight}[5]{\def\psk@optic@mirrorHeight{#1}}% it's the TOTAL height
\define@key[psset]{pst-optic}{mirrorWidth}[0.25]{\def\psk@optic@mirrorWidth{#1}}
\define@key[psset]{pst-optic}{mirrorColor}[lightgray]{\def\psk@optic@mirrorColor{#1}}
\define@key[psset]{pst-optic}{mirrorFocus}[8]{\def\psk@optic@mirrorFocus{#1}}
\define@key[psset]{pst-optic}{posMirrorTwo}[6]{\def\psk@optic@posMirrorTwo{#1}}% a sencond mirror? (telescope)
\define@key[psset]{pst-optic}{mirrorTwoAngle}[45]{\def\psk@optic@mirrorTwoAngle{#1}}% the angle for the 2. plan mirror (telescope)
\def\mirrorType{CVG}
\psset[pst-optic]{mirrorType=CVG,mirrorDepth=1,mirrorHeight=5,mirrorWidth=0.25,
   mirrorFocus=8,mirrorTwoAngle=45,posMirrorTwo=6,mirrorColor=lightgray}
%
% -------------- the refrectionnumbers -------------
%
\define@key[psset]{pst-optic}{refractA}[1]{\def\psk@optic@refractA{#1}}
\define@key[psset]{pst-optic}{refractB}[1.41]{\def\psk@optic@refractB{#1}}
\psset[pst-optic]{refractA=1,refractB=1.41}
%
% -------------- the length and node definitions -------------
%
\define@key[psset]{pst-optic}{XO}[0]{\def\psk@optic@XO{#1}}%		the X-offset
\define@key[psset]{pst-optic}{YO}[0]{\def\psk@optic@YO{#1}}%		the y-offset
\define@key[psset]{pst-optic}{posStart}[0]{\def\psk@optic@posStart{#1}}%	where the arrows start
\define@key[psset]{pst-optic}{length}[2]{\def\psk@optic@length{#1}}%	the length of the before|outlines
\define@key[psset]{pst-optic}{focus}[2]{\def\psk@optic@focus{#1}}%	for lenses/mirrors with a fixed focus
\define@key[psset]{pst-optic}{AB}[1]{\def\psk@optic@AB{#1}}%		the length of the object arrow
\define@key[psset]{pst-optic}{OA}[-3]{\def\psk@optic@OA{#1}}%		the xcoordinate of the object arrow
\define@key[psset]{pst-optic}{arrowOffset}[0]{\def\psk@optic@arrowOffset{#1}}%offset for \arrowLine
%
\psset[pst-optic]{XO=0,YO=0,OA=-3,posStart=0,length=2,focus=2,AB=1,arrowOffset=0}
%
\define@key[psset]{pst-optic}{nameA}[A]{\def\psk@optic@nameA{#1}}%	start of the object arrow
\define@key[psset]{pst-optic}{spotA}[270]{\def\psk@optic@spotA{#1}}%	where to draw the label
\define@key[psset]{pst-optic}{nameB}[B]{\def\psk@optic@nameB{#1}}
\define@key[psset]{pst-optic}{spotB}[90]{\def\psk@optic@spotB{#1}}
\define@key[psset]{pst-optic}{nameF}[F]{\def\psk@optic@nameF{#1}}
\define@key[psset]{pst-optic}{spotF}[270]{\def\psk@optic@spotF{#1}}
\define@key[psset]{pst-optic}{nameO}[O]{\def\psk@optic@nameO{#1}}
\define@key[psset]{pst-optic}{spotO}[225]{\def\psk@optic@spotO{#1}}
\define@key[psset]{pst-optic}{nameAi}[A']{\def\psk@optic@nameAi{#1}}
\define@key[psset]{pst-optic}{spotAi}[90]{\def\psk@optic@spotAi{#1}}
\define@key[psset]{pst-optic}{nameBi}[B']{\def\psk@optic@nameBi{#1}}
\define@key[psset]{pst-optic}{spotBi}[270]{\def\psk@optic@spotBi{#1}}
\define@key[psset]{pst-optic}{nameFi}[F']{\def\psk@optic@nameFi{#1}}
\define@key[psset]{pst-optic}{spotFi}[270]{\def\psk@optic@spotFi{#1}}
%
\psset[pst-optic]{nameA=A,spotA=270,nameB=B,spotB=90,nameF=F,spotF=270,
  nameO=O,spotO=225,nameAi=A',spotAi=90,nameBi=B',spotBi=270,
  nameFi=F',spotFi=270}
%
% -------------------- colors/fillstyles -------------------
%
\definecolor{BleuVerre}{cmyk}{0.2,0,0,0}
\definecolor{JauneVert}{cmyk}{0.3,0,1,0}
\newpsstyle{rayuresJaunes}{fillstyle=hlines,hatchsep=2\pslinewidth,hatchcolor=JauneVert}

\define@key[psset]{pst-optic}{rayColor}[red]{%
  \pst@getcolor{#1}\psk@optic@rayColor
  \pst@getcolor{#1}\psk@optic@parallelrayColor
  \def\psk@optic@paralleltipcolor{#1}%
  \pst@getcolor{#1}\psk@optic@focalrayColor
  \def\psk@optic@focaltipcolor{#1}%
  \pst@getcolor{#1}\psk@optic@centerrayColor
  \def\psk@optic@centertipcolor{#1}%
}
\define@key[psset]{pst-optic}{parallelrayColor}[red]{\pst@getcolor{#1}\psk@optic@parallelrayColor}
\define@key[psset]{pst-optic}{focalrayColor}[red]{\pst@getcolor{#1}\psk@optic@focalrayColor}
\define@key[psset]{pst-optic}{centerrayColor}[red]{\pst@getcolor{#1}\psk@optic@centerrayColor}

\psset[pst-optic]{rayColor=red}
\define@key[psset]{pst-optic}{rayWidth}[1.5\pslinewidth]{\def\psk@optic@rayWidth{#1}}
\psset[pst-optic]{rayWidth=1.5\pslinewidth}
%
\newpsstyle{opticalAxis}{linewidth=0.5pt,linecolor=black,linestyle=solid}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% Utility stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% posStart=Starting point
% length=  Arrow length.
\def\Arrows{\@ifnextchar[{\pst@Arrows}{\pst@Arrows[]}}
\def\pst@Arrows[#1](#2)(#3){{%
	\psset{#1}%
	\pst@getcoor{#2}\pst@tempA
	\pst@getcoor{#3}\pst@tempB
	\pnode(!%
		/StartArrow \psk@optic@posStart\space def
		/LengthArrow \psk@optic@length\space def
		\pst@tempA /YA exch \pst@number\psyunit div def
		/XA exch \pst@number\psxunit div def
		\pst@tempB /YB exch \pst@number\psyunit div def
		/XB exch \pst@number\psxunit div def
		/denominateur XB XA sub def
		/numerateur YB YA sub def
		/angleDirectionAB numerateur denominateur Atan def
		/XD StartArrow angleDirectionAB cos mul XA add def
		/YD StartArrow angleDirectionAB sin mul YA add def
		/XF XD LengthArrow angleDirectionAB cos mul add def
		/YF YD LengthArrow angleDirectionAB sin mul add def
		XD YD ){ArrowStart}%
	\pnode(! XF YF){ArrowEnd}%
	\psset{arrows=->}%
	\psline[#1](ArrowStart)(ArrowEnd)%
}\ignorespaces}
%
% draw a line (===) outside: #2-----#3=======#4
%
\def\psOutLine{\@ifnextchar[{\pst@ToDrawOut}{\pst@ToDrawOut[]}}
\def\pst@ToDrawOut[#1](#2)(#3)#4{{%
	\psset{#1}%
	\pst@getcoor{#2}\pst@tempA
	\pst@getcoor{#3}\pst@tempB
	\pnode(!%
		/LengthArrow \psk@optic@length\space def
		\pst@tempA /YA exch \pst@number\psyunit div def
		/XA exch \pst@number\psxunit div def
		\pst@tempB /YB exch \pst@number\psyunit div def
		/XB exch \pst@number\psxunit div def
		/denominateur XB XA sub def
		/numerateur YB YA sub def
		/angleDirectionAB numerateur denominateur Atan def
		/Xend XB LengthArrow angleDirectionAB cos mul add def
		/Yend YB LengthArrow angleDirectionAB sin mul add def
		Xend Yend){#4}
	\psline[#1](#3)(#4)
}}
%
% draw a line (===) before: #4========#2-----#3
%
\def\psBeforeLine{\@ifnextchar[{\pst@BeforeLine}{\pst@BeforeLine[]}}
\def\pst@BeforeLine[#1](#2)(#3)#4{{%
	\psset{#1}%
	\pst@getcoor{#2}\pst@tempA
	\pst@getcoor{#3}\pst@tempB
	\pnode(!%
		/LengthArrow \psk@optic@length\space def
		\pst@tempA /YA exch \pst@number\psyunit div def
		/XA exch \pst@number\psxunit div def
		\pst@tempB /YB exch \pst@number\psyunit div def
		/XB exch \pst@number\psxunit div def
		/denominateur XB XA sub def
		/numerateur YB YA sub def
		/angleDirectionAB numerateur denominateur Atan def
		/Xstart XA LengthArrow angleDirectionAB cos mul sub def
		/Ystart YA LengthArrow angleDirectionAB sin mul sub def
		Xstart Ystart){#4}
	\psline[#1](#4)(#2)%
}\ignorespaces}
%
% intersection de deux droites
% 2 juillet 2001/ rewritten 2003-01-27 Herbert
%
\def\ABinterCD(#1)(#2)(#3)(#4)#5{%
    \pst@getcoor{#1}\pst@tempA
    \pst@getcoor{#2}\pst@tempB
    \pst@getcoor{#3}\pst@tempc
    \pst@getcoor{#4}\pst@tempd
\pnode(!%
    /YA \pst@tempA exch pop \pst@number\psyunit div def
    /XA \pst@tempA pop \pst@number\psxunit div def
    /YB \pst@tempB exch pop \pst@number\psyunit div def
    /XB \pst@tempB pop \pst@number\psxunit div def
    /YC \pst@tempc exch pop \pst@number\psyunit div def
    /XC \pst@tempc pop \pst@number\psxunit div def
    /YD \pst@tempd exch pop \pst@number\psyunit div def
    /XD \pst@tempd pop \pst@number\psxunit div def
    /dY1 YB YA sub def
    /dX1 XB XA sub def
    /dY2 YD YC sub def
    /dX2 XD XC sub def
    dX1 abs 0.01 lt {
	/m2 dY2 dX2 div def
	XA dup XC sub m2 mul YC add 
    }{
	dX2 abs 0.01 lt {
	    /m1 dY1 dX1 div def
	    XC dup XA sub m1 mul YA add 
	}{%
	    /m1 dY1 dX1 div def
	    /m2 dY2 dX2 div def
	    m1 XA mul m2 XC mul sub YA sub YC add m1 m2 sub div dup
	    XA sub m1 mul YA add 
	} ifelse
    } ifelse ){#5}
}
%
% draw a parallel line
%     #2---------#3
%         #4----------#5(new)  
\def\Parallel{\@ifnextchar[{\pst@Parallel}{\pst@Parallel[]}}
\def\pst@Parallel[#1](#2)(#3)(#4)#5{{%
	\psset{#1}%
	\pst@getcoor{#2}\pst@tempA
	\pst@getcoor{#3}\pst@tempB
	\pst@getcoor{#4}\pst@tempc
	\pnode(!%
		/LengthArrow \psk@optic@length\space def
		\pst@tempA /YA exch \pst@number\psyunit div def
		/XA exch \pst@number\psxunit div def
		\pst@tempB /YB exch \pst@number\psyunit div def
		/XB exch \pst@number\psxunit div def
		\pst@tempc /YC exch \pst@number\psyunit div def
		/XC exch \pst@number\psxunit div def
		/denominateur XB XA sub def
		/numerateur YB YA sub def
		/angleDirectionAB numerateur denominateur Atan def
		/XstartParallel XC LengthArrow angleDirectionAB cos mul add def
		/YstartParallel YC LengthArrow angleDirectionAB sin mul add def
		XstartParallel YstartParallel){#5}
	\psline[#1](#4)(#5)
}}
%
% arrowLine[options](A)(B){n}
% #2---->---->---->---->----#3  #4-arrows inside
\def\arrowLine{\@ifnextchar[{\pst@arrowLine}{\pst@arrowLine[]}}
\def\pst@arrowLine[#1](#2)(#3)#4{{%
	\psset{arrowsize=4pt,arrows=->}% the defaults
	\psset{#1}%
	\def\pst@optic@n{#4}
	\pst@getcoor{#2}\pst@tempA
	\pst@getcoor{#3}\pst@tempB
	\pnode(!%
	    	/YA \pst@tempA exch pop \pst@number\psyunit div def
		/XA \pst@tempA pop \pst@number\psxunit div def
		/YB \pst@tempB exch pop \pst@number\psyunit div def
		/XB \pst@tempB pop \pst@number\psxunit div def
		/dY YB YA sub \pst@optic@n\space 1 add div def
		/dX XB XA sub \pst@optic@n\space 1 add div def
		/Alpha dY dX atan def
		/dYOffset \psk@optic@arrowOffset\space Alpha sin mul def
		/dXOffset \psk@optic@arrowOffset\space Alpha cos mul def
		XA YA ){tempArrowC}
	\multido{\i=1+1}{#4}{%
		\pnode(!%
			XA dX \i\space mul add dXOffset add
			YA dY \i\space mul add dYOffset add){tempArrowB}
		\psline(tempArrowC)(tempArrowB)
		\pnode(tempArrowB){tempArrowC}
    	}
	\psline[arrows=-](tempArrowB)(#3)
}\ignorespaces}
%
%   #1------#3------#2
\def\nodeBetween(#1)(#2)#3{%    Herbert 2003/01/05
    \pst@getcoor{#1}\pst@tempA
    \pst@getcoor{#2}\pst@tempB
    \pnode(!%
	/XA \pst@tempA pop \pst@number\psxunit div def
	/YA \pst@tempA exch pop \pst@number\psyunit div def
	/XB \pst@tempB pop \pst@number\psxunit div def
	/YB \pst@tempB exch pop \pst@number\psyunit div def
	XB XA add 2 div YB YA add 2 div){#3}
}
%
% rotateNode(A)
% (A) the node
% #2  the angle
% Herbert Voss <voss@perce.de> 2003-01-26
\def\rotateNode{\pst@rotateNode}
\def\pst@rotateNode(#1)#2{{%
    \pst@getcoor{#1}\pst@tempA
    \def\pst@optic@angle{#2}	% the rotating angle
    \pnode(!%
    	/YA \pst@tempA exch pop \pst@number\psyunit div def
	/XA \pst@tempA pop \pst@number\psxunit div def
	YA 0 eq XA 0 eq and {0 0}{
	    /r XA dup mul YA dup mul add Sqrt def
	    /AlphaOld YA XA atan def
	    /AlphaNew AlphaOld \pst@optic@angle\space add def
	    r AlphaNew cos mul r AlphaNew sin mul
	} ifelse ){temp}
    \pnode(temp){#1}
}\ignorespaces}
%
\def\rotateTriangle{\pst@rotateTriangle}
\def\pst@rotateTriangle(#1)(#2)(#3)#4{{%
    \rotateNode(#1){#4}
    \rotateNode(#2){#4}
    \rotateNode(#3){#4}
}\ignorespaces}
%
\def\rotateFrame{\pst@rotateFrame}
\def\pst@rotateFrame(#1)(#2)(#3)(#4)#5{{%
    \rotateNode(#1){#5}
    \rotateNode(#2){#5}
    \rotateNode(#3){#5}
    \rotateNode(#4){#5}
}\ignorespaces}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                              %
%                        L E N S E S	                          %
%                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A spherical lens is drawn only with a spherical bow
%
\def\lensSPH{\@ifnextchar[{\pst@lensSPH}{\pst@lensSPH[]}}
\def\pst@lensSPH[#1]{{%
	\psset[pst-optic]{lensType=CVG,OA=-7,%
		lensHeight=6,%
		lensWidth=1.5,%
		refractB=2,
		#1}
	\begin{pspicture*}(\psk@optic@xLeft ,\psk@optic@yBottom )
			(\psk@optic@xRight ,\psk@optic@yTop)
	\pnode(! \psk@optic@xLeft\space 0){xLeft}
	\pnode(! \psk@optic@xRight\space 0){xRight}
	\pstVerb{%
		/Height \psk@optic@lensHeight\space 2.0 div def
		/Depth \psk@optic@lensDepth\space def
		/Width \psk@optic@lensWidth\space def
		/Width2 Width 2.0 div def
	}
	\ifx\psk@optic@lensType\lensTypeCVG%	CVG ?
		\pnode(!%
			/radius Width2 dup mul Height dup mul add Width2 div 2 div def
			/XM Width2 radius sub def
			/YM 0 def
			XM YM){Center}
	\else%					DVG ?
		\pnode(!%
        /radius Depth dup mul Height dup mul add Depth div 2.0 div def
        /XM Width2 radius add neg def
        /YM 0 def
        XM YM){Center}
	\fi
% and vice versa
	\pnode(! XM neg 0){Center'}
	\pnode(!%
		/AB \psk@optic@AB\space def
		/OA \psk@optic@OA\space def
		/XO \psk@optic@XO\space def
		/YO \psk@optic@YO\space def
		OA XO add YO){A}
	\pnode(! OA XO add AB YO add){B}
	\pnode(! XO YO){O}
	\pnode(! XO AB YO add){I}
	\begingroup% for the fill option
	\psset{fillstyle=solid,%
		fillcolor=\psk@optic@lensColor,%
		linecolor=\psk@optic@lensColor%
	}
	\rput(! XO YO){%
		\ifx\psk@optic@lensType\lensTypeCVG% CVG
		\pscustom{%
              \parametricplot{\psk@optic@lensHeight}{-\psk@optic@lensHeight}{%
                  /arg t radius 2.0 mul div def 
                  arg 1 arg dup mul sub Sqrt atan 
                  cos 1 sub radius mul neg Width2 sub
                  t 2.0 div
		   }
              \parametricplot{-\psk@optic@lensHeight}{\psk@optic@lensHeight}{%
                  /arg t radius 2.0 mul div def 
                  arg 1 arg dup mul sub Sqrt atan 
                  cos 1 sub radius mul neg Width2 sub neg
                  t 2.0 div
		   }
	        \fill
		 }%
        \else 
           \pscustom{%
	        % (d+w/2,h/2)->(d-w,h/2)
	        \psline(! Depth Width2 add Height)(! Depth Width2 add neg Height)
	        % (-d-w/2,h/2)->(-d-w/2,-h/2)
	        \parametricplot{\psk@optic@lensHeight}{-\psk@optic@lensHeight}{%
                  /arg t 2.0 div radius div def 
                  arg 1 arg dup mul sub Sqrt atan cos 1 sub radius mul Width2 sub 
                  t 2.0 div
	        }
	        % (-d-w/2,-h/2)(d+w/2,-h/2)
	        \psline(! Depth Width2 add neg Height neg)(! Depth Width2 add Height neg)
	        % (d+w/2,-h/2)->(d+w/2,h/2)
	        \parametricplot{-\psk@optic@lensHeight}{\psk@optic@lensHeight}{%
                  /arg t 2.0 div radius div def 
                  1 arg 1 arg dup mul sub Sqrt atan cos sub radius mul Width2 add 
                  t 2.0 div
	        }
	        \fill
           }
         \fi%
       }%
	\endgroup
  \ifPst@drawing
    % optical axes
    \psline[style=opticalAxis](xLeft)(xRight)
    \psset{dotstyle=|}
    \psdots(Center')
    \uput[-90](Center'){Center'}
    \psdots(Center)
    \uput[-90](Center){Center}
    \psset{linecolor=\psk@optic@rayColor}   %%%%%%%%%%%%%%%%%%%%%%
    \psline[linewidth=1.5\pslinewidth,arrowinset=0]{->}(A)(B)
    \ifx\psk@optic@lensType\lensTypeCVG
      % the parallel ray
      \lensSPHRay[lensType=CVG]%
         (B)(I){\psk@optic@refractA}{\psk@optic@refractB}{PSPH}
      \ABinterCD(PSPH')(PSPH'')(O)(xRight){F'}
      \pst@getcoor{F'}\pst@tempf
      \pnode(!%
        /XF \pst@tempf pop \pst@number\psxunit div neg def
        /YF \pst@tempf exch pop \pst@number\psyunit div def
	   XF YF){F}
      \psline(B)(PSPH)(PSPH')(F')
      \psOutLine[length=5](PSPH')(F'){PEnd}
      % the center ray
      \lensSPHRay[lensType=CVG]%
        (B)(O){\psk@optic@refractA}{\psk@optic@refractB}{OSPH}
      \ABinterCD(PSPH')(PSPH'')(OSPH')(OSPH''){B'}
      \pnode(B'|0,0){A'}
      \psOutLine[length=5](OSPH')(OSPH''){OEnd}
      \psline(B)(OSPH)(OSPH')(OEnd)
      % the focus ray
      \lensSPHRay[lensType=CVG]%
         (B)(F){\psk@optic@refractA}{\psk@optic@refractB}{FSPH}
      \psOutLine[length=10](FSPH')(FSPH''){FEnd}
      \psline(B)(FSPH)(FSPH')(FEnd)
    \else % the DVG part
      % the parallel ray
      \lensSPHRay[lensType=DVG]%
         (B)(I){\psk@optic@refractA}{\psk@optic@refractB}{PSPH}
      \ABinterCD(PSPH')(PSPH'')(O)(xRight){F}
      \pst@getcoor{F}\pst@tempf
      \pnode(!%
        /XF \pst@tempf pop \pst@number\psxunit div def
        /YF \pst@tempf exch pop \pst@number\psyunit div def
   	   XF neg YF){F'}
      \psOutLine[linestyle=dashed,length=5](F)(PSPH'){PEnd'}
      \psOutLine[linestyle=dashed,length=5](PEnd')(PSPH'){PEnd}
      \psline(B)(PSPH)(PSPH')
      % the center ray
      \lensSPHRay[lensType=DVG]%
          (B)(O){\psk@optic@refractA}{\psk@optic@refractB}{OSPH}
      \ABinterCD(PSPH')(PSPH'')(OSPH')(OSPH''){B'}
      \pnode(B'|0,0){A'}
      \psOutLine(PSPH')(B'){PEnd}
      \psline(B)(OSPH)(OSPH')
      \psOutLine[linestyle=dashed,length=5](OSPH)(OSPH'){OEnd}
      % the focus ray
      \lensSPHRay[lensType=DVG]%
         (B)(F'){\psk@optic@refractA}{\psk@optic@refractB}{FSPH}
      \psline(B)(FSPH)(FSPH')(FSPH'')
      \psOutLine[length=5](FSPH')(FSPH''){FEnd}
      \psOutLine[linestyle=dashed,length=5](FSPH'')(FSPH'){FEnd'}
      \psline[linestyle=dashed](FSPH')(F')
    \fi
    \psdots(F')
    \uput[\psk@optic@spotFi](F'){$\mathrm{\psk@optic@nameFi}$}
    \uput[\psk@optic@spotF](F){$\mathrm{\psk@optic@nameF}$}
    \psline[linewidth=1.5\pslinewidth,arrowinset=0]{->}(A')(B')
    \uput[\psk@optic@spotA](A){$\mathrm{\psk@optic@nameA}$}
    \uput[\psk@optic@spotB](B){$\mathrm{\psk@optic@nameB}$}
    \uput[\psk@optic@spotAi](A'){$\mathrm{\psk@optic@nameAi}$}
    \uput[\psk@optic@spotBi](B'){$\mathrm{\psk@optic@nameBi}$}
    \uput[\psk@optic@spotO](O){$\mathrm{\psk@optic@nameO}$}
  \fi% ifdrawing
\end{pspicture*}%
}\ignorespaces}
%
% Herbert Voss 2003/02/02
% [#1]    : lensType=CVG/DVG
% (#2)(#3): the ray coordinates
% #4 #5:    the refraction numbers IN and OUT
% #6:       the intersection point
%
\def\lensSPHRay{\@ifnextchar[{\pst@lensSPHRay}{\pst@lensSPHRay[]}}
\def\pst@lensSPHRay[#1](#2)(#3)#4#5#6{{%
  \psset[pst-optic,pstricks]{#1}
  \ifx\psk@optic@lensType\lensTypeCVG% CVG
    \ifPst@rightRay
      \ABinterSPHLens(#2)(#3)(Center){#6}
    \else
      \ABinterSPHLens(#2)(#3)(Center'){#6}
    \fi
  \else
    \ABinterSPHLens(#2)(#3)(Center){#6}
  \fi
%  \psline(! Y mT sub X 1 sub neg)(! Y mT add X 1 add neg)
  \refractionRay(#2)(#6)(! Y mT sub X 1 sub neg)(! Y mT add X 1 add neg){#4}{#5}{tempSPHRay}
  \ifx\psk@optic@lensType\lensTypeCVG% CVG
    \ifPst@rightRay
      \ABinterSPHLens(#6)(tempSPHRay')(Center'){#6'}
    \else
      \ABinterSPHLens(#6)(tempSPHRay')(Center){#6'}
    \fi
  \else
    \ABinterSPHLens(#6)(tempSPHRay')(Center'){#6'}
  \fi
%  \psline(! Y mT sub X 1 sub neg)(! Y mT add X 1 add neg)
  \refractionRay(#6)(#6')(! Y mT sub X 1 sub neg)%
                (! Y mT add X 1 add neg){#5}{#4}{tempSPHRay}
  \pnode(tempSPHRay'){#6''}
}\ignorespaces}
%
% Intersection Point of ray and sperical lense
% 2003-02-03 Herbert
% (#1)(#2): the ray coordinates
% (#3):     The center of the sperical
% #4:       the intersection point
%
\def\ABinterSPHLens(#1)(#2)(#3)#4{%
  \pst@getcoor{#1}\pst@tempA
  \pst@getcoor{#2}\pst@tempB
  \pst@getcoor{#3}\pst@tempm
  % calculate the intersection point. we change the coordinates
  \ifx\psk@optic@lensType\lensTypeCVG% CVG
    \pnode(!%
      /YA \pst@tempA pop \pst@number\psxunit div def
      /XA \pst@tempA exch pop \pst@number\psyunit div neg def
      /YB \pst@tempB pop \pst@number\psxunit div def
      /XB \pst@tempB exch pop \pst@number\psyunit div neg def
      /YM \pst@tempm pop \pst@number\psxunit div def
      /XM \pst@tempm exch pop \pst@number\psyunit div neg def
%     /radius YM abs Width2 add def
      /dX XB XA sub def
      dX abs 0.01 lt {
% a horizontal line 
        /Y YM radius dup mul XA dup mul sub Sqrt YM 0 gt {sub}{add}ifelse def
        /YSecond YM radius dup mul XA dup mul sub Sqrt YM 0 gt {add}{sub}ifelse def
        /X XA def
        /XSecond XA def
        /mT XA radius dup mul XA dup mul sub Sqrt div YM 0 lt {neg}if def
        Y X neg
      }{
        /dY YB YA sub def
        /m dY dX div def
        /m21 m dup mul 1 add def
        /klammer YM m XA mul add YA sub def
        /p2neg klammer m mul m21 div def
        /q klammer dup mul radius dup mul sub m21 div def
        /root p2neg dup mul q sub Sqrt def
        /X p2neg root YM m mul 0 gt {sub}{add}ifelse def
        /XSecond p2neg root YM m mul 0 gt {add}{sub}ifelse def
        /Y m X XA sub mul YA add def
        /YSecond m XSecond XA sub mul YA add def
        /mT X radius dup mul X dup mul sub Sqrt div YM 0 lt {neg}if def
        Y X neg
      } ifelse){#4}
  \else% DVG
    \pnode(!%
      /YA \pst@tempA pop \pst@number\psxunit div def
      /XA \pst@tempA exch pop \pst@number\psyunit div neg def
      /YB \pst@tempB pop \pst@number\psxunit div def
      /XB \pst@tempB exch pop \pst@number\psyunit div neg def
      /YM \pst@tempm pop \pst@number\psxunit div def
      /XM \pst@tempm exch pop \pst@number\psyunit div neg def
%     /radius YM abs Width2 add def
      /dX XB XA sub def
      dX abs 0.01 lt {
% a horizontal line 
        /Y YM radius dup mul XA dup mul sub Sqrt YM 0 gt {sub}{add}ifelse def
        /YSecond YM radius dup mul XA dup mul sub Sqrt YM 0 gt {add}{sub}ifelse def
        /X XA def
        /mT XA radius dup mul XA dup mul sub Sqrt div YM 0 lt {neg}if def
        /XSecond XA def
        Y X neg
      }{
        /dY YB YA sub def
        /m dY dX div def
        /m21 m dup mul 1 add def
        /klammer YM m XA mul add YA sub def
        /p2neg klammer m mul m21 div def
        /q klammer dup mul radius dup mul sub m21 div def
        /root p2neg dup mul q sub Sqrt def
        /X p2neg root YM m mul 0 gt {sub}{add}ifelse def
        /XSecond p2neg root YM m mul 0 gt {add}{sub}ifelse def
        /Y m X XA sub mul YA add def
        /YSecond m XSecond XA sub mul YA add def
        /mT X radius dup mul X dup mul sub Sqrt div YM 0 lt {neg}if def
        Y X neg
      } ifelse){#4}
  \fi
  \pnode(! YSecond XSecond neg){#4'}
%\arrowLine[linecolor=blue,arrows=->](#4)(#4'){2}
}
%
\def\pst@drawDVGRays{%
    %dessin de l'objet
    \psline[linewidth=1.5\pslinewidth,arrowinset=0]{->}(A)(B)
% dessin de l'image
    \psline[linewidth=1.5\pslinewidth,arrowinset=0,linestyle=dashed]{->}(A')(B')
%dessin des rayons
%%    \psset{linecolor=\psk@optic@rayColor}
    %% center beam
    \Arrows[linecolor=\psk@optic@centerrayColor,length=16,arrows=-](B)(O)
    %% parallel beam
    \Arrows[linecolor=\psk@optic@parallelrayColor](B)(I)
    \psline[linecolor=\psk@optic@parallelrayColor](B)(I)
    \psOutLine[linecolor=\psk@optic@parallelrayColor,arrows=->,length=1](B')(I){END1}
    \psOutLine[linecolor=\psk@optic@parallelrayColor,length=5](B')(I){END2}
    \psline[linecolor=\psk@optic@parallelrayColor,linestyle=dashed](F')(I)
    %% focal beam
    \Arrows[linecolor=\psk@optic@focalrayColor,arrows=->>](B)(I')
    \psline[linecolor=\psk@optic@focalrayColor](B)(I')
    \psOutLine[linecolor=\psk@optic@focalrayColor,arrows=->>,length=2](B')(I'){END3}
    \psOutLine[linecolor=\psk@optic@focalrayColor,length=10](B')(I'){END4}
    \psline[linecolor=\psk@optic@focalrayColor,linestyle=dashed](B')(I')
    %\uput[45](I'){I'}
    %\uput[45](I){I}
    \uput[\psk@optic@spotA](A){$\mathrm{\psk@optic@nameA}$}%
    \uput[\psk@optic@spotB](B){$\mathrm{\psk@optic@nameB}$}%
    \uput[\psk@optic@spotAi](A'){$\mathrm{\psk@optic@nameAi}$}%
    \uput[\psk@optic@spotBi](B'){$\mathrm{\psk@optic@nameBi}$}%
    \uput[\psk@optic@spotO](O){$\mathrm{\psk@optic@nameO}$}%
}
\def\pst@drawCVGRays{%
% Position des foyers
  \psdots[dotstyle=|](F')
  \uput[\psk@optic@spotFi](F'){$\mathrm{\psk@optic@nameFi}$}
  \psdots[dotstyle=|](F)
  \uput[\psk@optic@spotF](F){$\mathrm{\psk@optic@nameF}$}
%dessin de l'objet
  \psline[linewidth=1.5\pslinewidth,arrowinset=0]{->}(A)(B)
% dessin de l'image
  \psline[linewidth=1.5\pslinewidth,arrowinset=0]{->}(A')(B')
%dessin des rayons
%  \psset{linecolor=\psk@optic@rayColor}%% No global setting
  %% Center beam
  \pcline[linecolor=\psk@optic@centerrayColor](B)(B')%%CMittelpunktsstrahl
  \Arrows[linecolor=\psk@optic@centerrayColor,length=16,arrows=-](B)(O)
  \Arrows[linecolor=\psk@optic@centerrayColor](B)(I)
  %% parallel beam
  \psline[linecolor=\psk@optic@parallelrayColor,tipcolor=\psk@optic@paralleltipcolor](B)(I)
  \Arrows[linecolor=\psk@optic@parallelrayColor](B)(I)
  \Arrows[linecolor=\psk@optic@parallelrayColor,length=10,posStart=0,arrows=-](I)(F')
  \Arrows[linecolor=\psk@optic@parallelrayColor,posStart=1,arrows=->](I)(F')
  %% focal beam
  \psline[linecolor=\psk@optic@focalrayColor](B)(I')(B')
  \Arrows[linecolor=\psk@optic@focalrayColor,arrows=->>](B)(I')
  \Arrows[linecolor=\psk@optic@focalrayColor,length=10,arrows=-](I')(B')
  \Arrows[linecolor=\psk@optic@focalrayColor,length=2,posStart=0.5,
          arrows=->>,tipcolor=\psk@optic@focaltipcolor](I')(B')
  %\uput[-45](I'){I'}
  %\uput[45](I){I}
  \uput[\psk@optic@spotA](A){$\mathrm{\psk@optic@nameA}$}
  \uput[\psk@optic@spotB](B){$\mathrm{\psk@optic@nameB}$}
  \uput[\psk@optic@spotAi](A'){$\mathrm{\psk@optic@nameAi}$}
  \uput[\psk@optic@spotBi](B'){$\mathrm{\psk@optic@nameBi}$}
  \uput[\psk@optic@spotO](O){$\mathrm{\psk@optic@nameO}$}
}
%fin 26 juin 2001
%Lentille convergente : CVG
%(#2) est l'abscisse du centre optique
\def\lens{\@ifnextchar[{\pst@lens}{\pst@lens[]}}
\def\pst@lens[#1]{%
  \begingroup
  \psset[pst-optic,pstricks]{xLeft=-7.5,xRight=7.5,yBottom=-3,yTop=3,#1}%
%  \psset[pst-optic,pstricks]{#1}%
  \pst@killglue%
% trace les rayons
% calcule la position de l'image
  \begin{pspicture*}(\psk@optic@xLeft,\psk@optic@yBottom)(\psk@optic@xRight,\psk@optic@yTop)
    \pnode(! \psk@optic@xLeft\space 0){xLeft}%
    \pnode(! \psk@optic@xRight\space 0){xRight}%
    \ifPst@lensTwo
      \pnode(!%
        /OF' \psk@optic@focus\space def
        %/AB \psk@optic@AB\space def
	   /AB A'1B'1 def
        %/OA \psk@optic@OA\space def
        /XO \psk@optic@XO\space def
        /YO \psk@optic@YO\space def
        /OA XO neg XO1 add O1A1' add def
        /TesT OA OF' add def
        TesT 0 eq {/OA OF' neg 0.001 add def} if
        /OA' OA OF' mul OA OF' add div def
        /Gamma OA' OA div def
        /A'B' Gamma AB mul def
        OA' XO add YO){A'}%
      \pnode(! OA XO add YO){A}%
      \pnode(! OA XO add AB YO add){B}
      \pnode(! OF' XO add YO){F'}
      \pnode(! OF' neg XO add YO){F}
      \pnode(! OA' XO add A'B' YO add){B'}
      \pnode(! XO YO){O}
      \pnode(! XO AB YO add){I}
      \pnode(! XO A'B' YO add){I'}
      \pnode(! \psk@optic@xRight\space A'B' YO add){I1}
      \pnode(! \psk@optic@xRight\space neg A'B' YO add){I2}
    \else%
      \pnode(!
	   /OF' \psk@optic@focus\space def
	   /AB \psk@optic@AB\space def
	   /OA \psk@optic@OA\space def
	   /XO \psk@optic@XO\space def
	   /YO \psk@optic@YO\space def
	   /TesT OA OF' add def
	   TesT 0 eq {/OA OF' neg 0.001 add def} if
	   /OA' OA OF' mul OA OF' add div def
	   /Gamma OA' OA div def
	   /A'B' Gamma AB mul def
	   OA' XO add YO){A'}
      \pnode(! OA XO add YO){A}%
      \pnode(! OA XO add AB YO add){B}%
      \pnode(! OF' XO add YO){F'}%
      \pnode(! OF' neg XO add YO){F}%
      \pnode(! OA' XO add A'B' YO add){B'}%
      \pnode(! XO YO){O}%
      \pnode(! XO AB YO add){I}%
      \pnode(! XO A'B' YO add){I'}%
      \pnode(! \psk@optic@xRight\space A'B' YO add){I1}%
      \pnode(! \psk@optic@xRight\space neg A'B' YO add){I2}%
    \fi%
    \ifPst@onlyrays\else
    \begingroup%
      \ifPst@lensGlass
        \rput(! XO YO){%
	      \ifx\psk@optic@lensType\lensTypeCVG \lensCVG%
	      \else\ifx\psk@optic@lensType\lensTypePCVG \lensCVG
 	        \else\lensDVG
 	      \fi\fi}%
      \else
        \ifx\psk@optic@lensType\lensTypeDVG 
          \psset{arrows=>-<}
        \else
          \ifx\psk@optic@lensType\lensTypePDVG
            \psset{arrows=>-<}%
          \else
            \psset{arrows=<->}%
	    \fi\fi
        \psline[linecolor=\psk@optic@lensColor,
          linewidth=2\pslinewidth, %\psk@optic@lensWidth,
          arrowsize=\psk@optic@lensArrowSize,
          arrowinset=\psk@optic@lensArrowInset]%
          (! XO -0.5 \psk@optic@lensHeight\space mul 
             \psk@optic@lensScale\space mul YO add)%
          (! XO 0.5 \psk@optic@lensHeight\space mul 
             \psk@optic@lensScale\space mul YO add)%
	 \fi%
    \endgroup
    \fi
  \ifPst@drawing
% axe optique
    \psline[style=opticalAxis](! \psk@optic@xLeft\space YO)(! \psk@optic@xRight\space YO)
    \ifx\psk@optic@lensType\lensTypeDVG\pst@drawDVGRays\else
      \ifx\psk@optic@lensType\lensTypePDVG\pst@drawDVGRays\else
        \pst@drawCVGRays\fi\fi
  \fi
  \end{pspicture*}%
  \endgroup
  \ignorespaces}
%
% 25 december 2002 Herbert <voss@perce.de>
% make the lenses dynamical to width _and_ height
% \pslens calculates the radius and the angles from the given values
% of lensWidth and lensHeight and draws the lens with it's origin (0,0)
% 
\def\pslensDVG{\pst@object{pslensDVG}}
\def\pslensDVG@i#1#2{%
  \begin@OpenObj
  \pssetlength\pst@dima{#1}%
  \pssetlength\pst@dimb{#2}%
  \ifx\psk@optic@lensType\lensTypeDVG\addto@pscode{\pslensDVG@ii}%
  \else\addto@pscode{\pslensPDVG@ii}\fi%
  \end@OpenObj%
}
\def\pslensDVG@ii{%
	/w \pst@number\pst@dima def% lensWidth
	/wHalbe w 2 div def% half of the width
	/h \pst@number\pst@dimb 2 div def% the half of the height
	/Radius wHalbe 2 div dup mul h dup mul add wHalbe div def
	/x Radius wHalbe 2 div add def
	/y 0 def
	/angleA h x wHalbe sub atan neg def
	/angleB angleA neg def
	wHalbe h moveto
	x y Radius 180 angleA add 180 angleB add arc
	x neg y Radius angleA angleB arc
	wHalbe h lineto
}
\def\pslensPDVG@ii{%
	/w \pst@number\pst@dima def% lensWidth
	/wHalbe w 2 div def% half of the width
	/h \pst@number\pst@dimb 2 div def% the half of the height
	/Radius wHalbe 2 div dup mul h dup mul add wHalbe div def
	/x Radius wHalbe 2 div add def
	/y 0 def
	/angleA h x wHalbe sub atan neg def
	/angleB angleA neg def
	0 h moveto
	wHalbe 0 rlineto 
	x y Radius 180 angleA add 180 angleB add arc 
%	x neg y Radius angleA angleB arc
	wHalbe neg 0 rlineto
	0 h dup add rlineto
}
%
\def\pslensCVG{\pst@object{pslensCVG}}
\def\pslensCVG@i#1#2{%
  \begin@OpenObj
  \pssetlength\pst@dima{#1}%
  \pssetlength\pst@dimb{#2}%
  \ifx\psk@optic@lensType\lensTypeCVG\addto@pscode{\pslensCVG@ii}%
  \else\addto@pscode{\pslensPCVG@ii}\fi%
  \end@OpenObj%
}
%
\def\pslensCVG@ii{%
  /w \pst@number\pst@dima def% lensWidth
  /wHalbe w 2 div def% half of the width
  /h \pst@number\pst@dimb 2 div def% the half of the height
  /Radius wHalbe dup mul h dup mul add w div def
  /x Radius wHalbe sub def
  /y 0 def
  /angleA h x atan neg def
  /angleB angleA neg def
  0 h moveto
  x y Radius 180 angleA add 180 angleB add arc
  x neg y Radius angleA angleB arc
}
\def\pslensPCVG@ii{%
  /w \pst@number\pst@dima def% lensWidth
  /wHalbe w 2 div def% half of the width
  /h \pst@number\pst@dimb 2 div def% the half of the height
  /Radius wHalbe dup mul h dup mul add w div def
  /x Radius wHalbe sub def
  /y 0 def
  /angleA h x atan neg def
  /angleB angleA neg def
  0 h neg moveto
  0 h dup add rlineto
  x neg y Radius angleA angleB arc
}
%
%22 juin 2001 / 25 december 2002
%Choisir la forme et la taille de la lentille
%Le dessin de la lentille
%
\def\lensCVG{%
  \psscalebox{\psk@optic@lensScale}{%
    \pscustom[linewidth=0.75\pslinewidth]{%
      \pslensCVG{\psk@optic@lensWidth}{\psk@optic@lensHeight}
      \fill[fillstyle=solid,fillcolor=BleuVerre]
    }%
  }%
}
%
\def\lensDVG{%
  \psscalebox{\psk@optic@lensScale}{%
    \pscustom[linewidth=0.75\pslinewidth]{%
      \pslensDVG{\psk@optic@lensWidth}{\psk@optic@lensHeight}
      \fill[fillstyle=solid,fillcolor=BleuVerre]%
    }%
  }%
}
%Sauvegarde des points pour le cas d'un
%système à deux lentilles (26 juin 2001)
\def\Transform{%
    \pnode(A){A1}
    \pnode(B){B1}
    \pnode(A'){A'1}
    \pnode(B'){B'1}
    \pnode(O){O1}
    \pnode(F){F1}
    \pnode(F'){F'1}
    \pnode(I){I11}
    \pnode(I'){I'1}
    \pnode(!%
        /XO1 XO def
        /YO1 YO def
        /O1A1' OA' def
        /A'1B'1 A'B' def
        XO1 YO1){factice}
}
%
%intersection d'un rayon avec une lentille
\def\rayInterLens(#1)(#2)#3#4{{%
    \pst@getcoor{#1}\pst@tempA
    \pst@getcoor{#2}\pst@tempB
    \pnode(!%
	/LengthArrow \psk@optic@length\space def
	\pst@tempA /YE1 exch \pst@number\psyunit div def
	/XE1 exch \pst@number\psxunit div def
	\pst@tempB /YB1 exch \pst@number\psyunit div def
	/XB1 exch \pst@number\psxunit div def
	/XO2 #3 def
	/YO2 YB1 YE1 sub
	XB1 XE1 sub div
	XO2 XE1 sub
	mul
	YE1 add
	def
	XO2 YO2){#4}
}}
%
%eye du philatéliste
\def\eye{%
    \psarc[linewidth=2pt](0,2.5){2.5}{215}{270}%
    \psarc[linewidth=2pt](0,-2.5){2.5}{90}{140}%
    \psarc(-2.5,0){1}{-30}{30}%
    \psarc(0,0){1.75}{160}{200}
    \psclip{%
	\pscircle[linestyle=none](0,0){1.75}}
    \pscircle[fillstyle=solid,fillcolor=lightgray](-2.5,0){0.9}
    \endpsclip%
}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                              %
%                    M I R R O R S                             %
%                                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\def\mirrorCVGRay{\@ifnextchar[{\pst@mirrorCVGRay}{\pst@mirrorCVGRay[]}}% Herbert 2003/01/05
\def\pst@mirrorCVGRay[#1](#2)(#3)#4{{%
  \ifx\relax#1\relax \else\psset[pst-optic,pstricks]{#1}\fi%
  \ifx\psk@optic@mirrorType\mirrorType % CVG
%\typeout{====>\mirrorType}
%\typeout{====>\psk@optic@mirrorType}
    \pst@getcoor{#2}\pst@tempA
    \pst@getcoor{#3}\pst@tempB
    \pnode(!%
      \psk@optic@mirrorHeight\space dup mul 16 div 
      \psk@optic@mirrorDepth\space div XO add YO){Focus}
      \pnode(!%
	  /Xmax \psk@optic@mirrorHeight\space 2 div def
	  /Ymax \psk@optic@mirrorDepth\space def
	  /A 2 \psk@optic@mirrorHeight\space div dup mul Ymax mul def
	  /XA \pst@tempA exch pop \pst@number\psyunit div neg def
	  /YA \pst@tempA pop \pst@number\psxunit div def
	  /XB \pst@tempB exch pop \pst@number\psyunit div neg def
	  /YB \pst@tempB pop \pst@number\psxunit div def
	  XB XA sub abs 0.01 lt {A XA dup mul mul XA neg}{
	    /m YB YA sub XB XA sub div def
	    /m2a m A div 2 div def
	    /Root m2a dup mul m XA mul YA sub A div sub Sqrt def
	    /Xp m2a Root add XA sub def
	    /Xn m2a Root sub XA sub def
	    /YSp m Xp mul YA add def
	    /XSp Xp XA add neg def
	    /YSn m Xn mul YA add def
	    /XSn Xn XA add neg def
	    YA 0 eq {0 0}{XB XA lt {YSn XSn}{YSp XSp} ifelse} ifelse} ifelse) {#4}
    \pst@getcoor{#2}\pst@tempc% the starting point
    \pst@getcoor{#4}\pst@tempA% the point on the mirror
        \pnode(!%
	/XA \pst@tempA exch pop \pst@number\psyunit div neg def
	/YA \pst@tempA pop \pst@number\psxunit div def
	/XC \pst@tempc exch pop \pst@number\psyunit div neg def
	/YC \pst@tempc pop \pst@number\psxunit div def
% Mittelpunktsstrahl?
	XA abs 0.01 lt YA abs 0.01 lt and {%
	    /NoMoreReflection true def 
	    YC XC
	}{%
	    /DY YA YC sub def
	    /DX XA XC sub def
% Steigung der Tangente im Punkt (XA|YA) y'=2ax
	    /mRay A XA mul 2 mul def
% zugehoeriger Steigungswinkel alpha=arctan y'
	    /Alpha mRay 2 div 0.5 atan def
% das dazugehoerige Lot
	    /AlphaPerp 1.0 neg mRay atan def
% Winkel des einfallenden Strahls
	    /Beta DY DX atan def
% Winkel des ausfallenden Strahls
	    /BetaStrich AlphaPerp 2 mul Beta sub def 
% senkrechte Steigung? cos BetaStrich = 0 
	    BetaStrich cos abs 0.1 lt {%
		/NoMoreReflection true def 
		Ymax 2 mul XA neg
	    }{%
% Steigung
		/m BetaStrich sin BetaStrich cos div def
% Steigung, ab der kein Schnittpunkt mehr stattfindet
		/mMax 2 A mul Xmax mul def
		m abs mMax gt {
% no more second reflection
		    /NoMoreReflection true def 
		    Ymax 2 mul dup YA sub m div XA add neg
		}{
% moegliche 2. Reflektion
		    /NoMoreReflection false def 
% pq Formel anwenden
		    /m2a m A div 2 div def
		    /Root m2a dup mul m XA mul YA sub A div sub Sqrt def
		    /X1 m2a Root add def
		    /X2 m2a Root sub def
% be sure, that we get the right point
		    /X XA X1 sub abs 0.01 gt {X1}{X2} ifelse def
		    /Y A X dup mul mul def
    		    Y X neg
		} ifelse 
	    } ifelse
	} ifelse){#4'}
    \pst@getcoor{#2}\pst@tempA
    \pst@getcoor{#4'}\pst@tempB
    \pst@getcoor{#4}\pst@tempc
    \pnode(!%
	/XB \pst@tempB exch pop \pst@number\psyunit div neg def
	/YB \pst@tempB pop \pst@number\psxunit div def
	NoMoreReflection
	    {YB XB neg}{%
	    /XC \pst@tempc exch pop \pst@number\psyunit div neg def
	    /YC \pst@tempc pop \pst@number\psxunit div def
	    /XAtemp \pst@tempA exch pop \pst@number\psyunit div neg def
	    /YAtemp \pst@tempA pop \pst@number\psxunit div def
	    /m1 2 A mul XB mul def
	    /Alpha2 m1 abs 0.01 lt {90}{1 neg m1 atan} ifelse def
	    /Beta XB XC sub abs 0.01 gt 
		{YC YB sub XC XB sub atan}
		{90} ifelse def
	    /Gamma Alpha2 Beta sub def
	    /Delta Alpha2 Gamma add def
	    Delta cos abs 0.01 gt {%
		/mDelta Delta sin Delta cos div def
		/X YAtemp YB sub mDelta div XB add neg def}{%
		/X XB neg def} ifelse
	    m1 abs 0.01 lt {YAtemp XAtemp}{YAtemp X} ifelse 
	} ifelse ){#4''}
    \else
%--------------- A Spherical Mirror -----------------
%\typeout{====>\mirrorType}
%\typeout{====>\psk@optic@mirrorType}
      \ABinterSPHLens(#2)(#3)(Center){tempRef0}
    	 \pst@getcoor{tempRef0}\pst@tempA
    	 \pst@getcoor{tempRef0'}\pst@tempB
      \pnode(!%
        \pst@tempA /Y1 exch \pst@number\psyunit div def
        /X1 exch \pst@number\psxunit div def
        \pst@tempB /Y2 exch \pst@number\psyunit div def
        /X2 exch \pst@number\psxunit div def
        X1 X2 lt {X1 Y1}{X2 Y2}ifelse ){#4}
      \reflectionRay[#1](#2)(#4){tempRef1}
% we try if we have another intermediate point
      \ABinterSPHLens(#4)(tempRef1)(Center){tempRef2}
    	 \pst@getcoor{#4}\pst@tempA
    	 \pst@getcoor{tempRef2}\pst@tempB
    	 \pst@getcoor{tempRef2'}\pst@tempc
      \pnode(!%
        \pst@tempA /YP exch \pst@number\psyunit div def
        /XP exch \pst@number\psxunit div def
        \pst@tempB /Y1 exch \pst@number\psyunit div def
        /X1 exch \pst@number\psxunit div def
        \pst@tempc /Y2 exch \pst@number\psyunit div def
        /X2 exch \pst@number\psxunit div def
          XP X1 sub abs 0.01 gt {X1 Y1}{X2 Y2} ifelse ){#4'}
      \reflectionRay[#1](tempRef1)(#4'){#4''}
    \psset[pst-optic]{mirrorType=CVG}% restore
    \fi
    \ifPst@drawing
	\psline[#1](#2)(#4)
	\psline[#1](#4)(#4')
	\psline[#1](#4')(#4'')
    \fi
}\ignorespaces}
%
%
\def\mirrorCVG{\@ifnextchar[{\pst@mirrorCVG}{\pst@mirrorCVG[]}}%  Herbert Voss 2003/01/05
\def\pst@mirrorCVG[#1]{{%
  \psset[pst-optic]{AB=1.25,OA=4.5,XO=0,YO=0,xLeft=-5,xRight=5,yBottom=-3,yTop=3,
     mirrorHeight=5,mirrorDepth=1,mirrorWidth=0.2}%
  \ifx\relax#1\relax \else\psset[pst-optic,pstricks]{#1}\fi%
  \def\mirrorType{CVG}%
  \begin{pspicture}(\psk@optic@xLeft,\psk@optic@yBottom)(\psk@optic@xRight,\psk@optic@yTop)
    \pnode(\psk@optic@xLeft, 0){xLeft}
    \pnode(\psk@optic@xRight, 0){xRight}
    \pstVerb{
	/Height \psk@optic@mirrorHeight\space 2.0 div def
	/Depth \psk@optic@mirrorDepth\space def
	/Width \psk@optic@mirrorWidth\space def
	/AB \psk@optic@AB\space def
	/OA \psk@optic@OA\space def
	/XO \psk@optic@XO\space def
	/YO \psk@optic@YO\space def
        /radius Height dup mul Depth dup mul add 2 div Depth div def 
    }
    \pnode(! OA XO add YO){A}
    \pnode(! OA XO add AB YO add){B}
    \pnode(! XO YO){O}
    \ifx\psk@optic@mirrorType\mirrorType % CVG
      \pnode(!
	\psk@optic@mirrorHeight\space dup mul 16 div 
	\psk@optic@mirrorDepth\space div XO add YO){Focus}
    \else % SPH
      \pnode(! radius XO add YO){Center}
      \pnode(! radius 2 div XO add YO){Focus}
    \fi
    \pscustom[fillstyle=solid,fillcolor=\psk@optic@mirrorColor,
	   linecolor=\psk@optic@mirrorColor]{%
	% (d,h/2)->(d-w,h/2)
      \psline(!%
        \psk@optic@mirrorDepth\space \psk@optic@mirrorHeight\space 2 div)(!%
        \psk@optic@mirrorDepth\space \psk@optic@mirrorWidth\space sub 
        \psk@optic@mirrorHeight\space 2 div)
      % (-w/2,h/2)->(-w/2,-h/2)
      \ifx\psk@optic@mirrorType\mirrorType % CVG or SPH
        \parametricplot{\psk@optic@mirrorHeight}{-\psk@optic@mirrorHeight}{%
          2 \psk@optic@mirrorHeight\space div dup mul \psk@optic@mirrorDepth\space mul 
          t 2 exp 4 div mul \psk@optic@mirrorWidth\space sub t 2 div }
      \else
        \parametricplot{\psk@optic@mirrorHeight}{-\psk@optic@mirrorHeight}{%
            /radD radius \psk@optic@mirrorWidth\space add def
            radius \psk@optic@mirrorWidth\space sub radD dup mul t 2 div dup mul sub Sqrt sub t 2 div }
      \fi
	% (d-w,-h/2)(d,-h/2)
      \psline(!%
          \psk@optic@mirrorDepth\space \psk@optic@mirrorWidth\space sub
          \psk@optic@mirrorHeight\space 2 div neg)(!%
          \psk@optic@mirrorDepth\space \psk@optic@mirrorHeight\space 2 div neg)
	% (w/2,-h/2)->(w/2,h/2)
      \ifx\psk@optic@mirrorType\mirrorType % CVG or SPH
          \parametricplot{-\psk@optic@mirrorHeight}{\psk@optic@mirrorHeight}{
	    2 \psk@optic@mirrorHeight\space div dup mul \psk@optic@mirrorDepth\space mul 
	    t 2 exp 4 div mul t 2 div }
      \else
	  \parametricplot{-\psk@optic@mirrorHeight}{\psk@optic@mirrorHeight}{
            radius dup dup mul t 2 div dup mul sub Sqrt sub t 2 div }
      \fi
      \fill
    }%
    \ifPst@drawing
      \psline[style=opticalAxis](O)(xRight)
      \ifx\psk@optic@mirrorType\mirrorType\qdisk(Center){1.5pt}\uput{0.2}[-90](Center){Center}\fi
      \qdisk(Focus){2pt}\uput[0](Focus){F}
      \psline[linewidth=3\pslinewidth]{->}(A)(B)
      \psset{linewidth=\pslinewidth,linecolor=\psk@optic@rayColor,arrows=>}
      \uput[0](A){A}
      \uput[0](B){B}
      \pnode(! 1 \psk@optic@AB\space){Dummy}
      \mirrorCVGRay[drawing=false](B)(Dummy){PR}
      \psOutLine[length=\psk@optic@OA](PR)(PR'){PR''}
      \nodeBetween(B)(PR){Dummy}
      \psline(B)(Dummy)
      \psline(Dummy)(PR)
      \nodeBetween(PR)(PR''){Dummy}
      \psline(PR)(Dummy)
      \psline(Dummy)(PR'')
%
	\mirrorCVGRay[drawing=false](B)(0, 0){MR}
     \psOutLine[length=\psk@optic@OA](MR)(MR'){MR''}
	\nodeBetween(B)(MR){Dummy}
	\psline(B)(Dummy)
	\psline(Dummy)(MR)
	\nodeBetween(MR)(MR'){Dummy}
	\psline(MR)(Dummy)
	\psline(Dummy)(MR')
%
	\mirrorCVGRay[drawing=false](B)(Focus){FR}
     \psOutLine[length=\psk@optic@OA](FR)(FR'){FR''}
	\nodeBetween(B)(FR){Dummy}
	\psline(B)(Dummy)
	\psline(Dummy)(FR)
	\nodeBetween(FR)(FR'){Dummy}
	\psline(FR)(Dummy)
	\psline(Dummy)(FR')
%
     \ABinterCD(PR)(PR')(FR)(FR'){B'}
     \pnode( B'|0,0 ){A'}
     \psline[linecolor=black,linewidth=3\pslinewidth,arrows=->](A')(B')
     \uput[45](A'){A'}
     \uput[-45](B'){B'}
    \fi
    \end{pspicture}%
  }%
  \ignorespaces
}
%
%
\def\mirrorDVG{\@ifnextchar[{%  Herbert Voss 2003/01/05
    \pst@mirrorDVG}{\pst@mirrorDVG[]}}
\def\pst@mirrorDVG[#1]{{%
  \psset[pst-optic]{%	the defaults
    AB=1.25,OA=4,XO=0,YO=0,xLeft=-5,xRight=5,yBottom=-3,yTop=3,%
    mirrorHeight=5,mirrorDepth=1,mirrorWidth=0.2,mirrorType=DVG}%
  \def\mirrorType{DVG}%
  \psset[pst-optic,pstricks]{#1}%
  \pstVerb{
    /Height \psk@optic@mirrorHeight\space 2 div def
    /Depth \psk@optic@mirrorDepth\space def
    /Width \psk@optic@mirrorWidth\space def
    /radius Height dup mul Depth dup mul add 2 div Depth div def 
    /AB \psk@optic@AB\space def
    /OA \psk@optic@OA\space def
    /XO \psk@optic@XO\space def
    /YO \psk@optic@YO\space def
  }
  \begin{pspicture}(\psk@optic@xLeft,\psk@optic@yBottom)(\psk@optic@xRight,\psk@optic@yTop)
  \pnode(! \psk@optic@xLeft\space 0){xLeft}
  \pnode(! \psk@optic@xRight\space 0){xRight}
  \pnode(! OA XO add YO){A}
  \pnode(! OA XO add AB YO add){B}
  \pnode(! XO YO){O}
  \ifx\psk@optic@mirrorType\mirrorType % DVG
	\pnode(! Height dup mul 4 div Depth div XO add YO){Focus}
  \else                                % SPH
	\pnode(! radius neg XO add YO){Center}
	\pnode(! radius 2 div XO add YO){Focus}
  \fi
  \pscustom[fillstyle=solid,%
	fillcolor=\psk@optic@mirrorColor,%
	linecolor=\psk@optic@mirrorColor]{%
	% (d,h/2)->(d-w,h/2)
	\psline(! Depth neg Height)(! Depth Width add neg Height)
	% (-w/2,h/2)->(-w/2,-h/2)
	\ifx\psk@optic@mirrorType\mirrorType
  	  \parametricplot{\psk@optic@mirrorHeight}{-\psk@optic@mirrorHeight}{%
      	    Depth Height dup mul div t 2 exp 4 div mul neg t 2 div }
	\else
	  \parametricplot{\psk@optic@mirrorHeight}{-\psk@optic@mirrorHeight}{%
	    radius dup mul t 2 div dup mul sub Sqrt radius sub t 2 div }
	\fi
	% (d-w,-h/2)(d,-h/2)
	\psline(! Depth Width add neg Height neg)(! Depth neg Height neg)%
	% (w/2,-h/2)->(w/2,h/2)
	\ifx\psk@optic@mirrorType\mirrorType
	  \parametricplot{-\psk@optic@mirrorHeight}{\psk@optic@mirrorHeight}{%
	    Depth Height dup mul div t 2 exp 4 div mul neg Width sub t 2 div }
	\else
 	  \parametricplot{-\psk@optic@mirrorHeight}{\psk@optic@mirrorHeight}{%
	    radius Width sub dup mul t 2 div dup mul sub Sqrt radius sub t 2 div }
	\fi
        \fill%
  }
  \ifPst@drawing
    \psline[style=opticalAxis](xLeft)(xRight)
    \qdisk(Center){2pt}\uput[-90](Center){C}
    \qdisk(Focus){2pt}\uput{0.25}[-90](Focus){F}
    \psline[linewidth=3\pslinewidth,arrowinset=0]{->}(A)(B)
    \psset{linewidth=1.5\pslinewidth,linecolor=\psk@optic@rayColor,arrows=->}
    \uput{0.15}[0](A){A}
    \uput{0.15}[0](B){B}
%
    \mirrorDVGRay[drawing=false](B)(0,\psk@optic@AB){PR}
%	mirrorType=\psk@optic@mirrorType,drawing=false](B)(0,\psk@optic@AB){PR}
    \qdisk(PR){1.5pt}\uput{0.2}[180](PR){PR}
    \qdisk(PR'){1.5pt}\uput{0.2}[0](PR'){PR'}
    \nodeBetween(B)(PR){PDummy}
    \psline(B)(PDummy)
    \psline(PDummy)(PR)
    \psline[arrows=-, linestyle=dotted](Focus)(PR)
    \psOutLine[arrows=-,linestyle=dotted](P)(Focus){PBegin}
    \psline(PR)(PR')
%
    \mirrorDVGRay[drawing=false](B)(! 0 0){MR}
%	mirrorType=\psk@optic@mirrorType,%
    \qdisk(MR){1.5pt}\uput{0.2}[180](MR){MR}
    \qdisk(MR'){1.5pt}\uput{0.2}[0](MR'){MR'}
    \nodeBetween(B)(! 0 0){MDummy}
    \psline(B)(MDummy)
    \psline(MDummy)(! 0 0)
    \psline(MR)(MR')
%
    \mirrorDVGRay[drawing=false](B)(Focus){FR}
%			mirrorType=\psk@optic@mirrorType,%
    \qdisk(FR){1.5pt}\uput{0.2}[180](FR){FR}
    \qdisk(FR'){1.5pt}\uput{0.2}[0](FR'){FR'}
    \nodeBetween(B)(FR){Dummy}
    \psline(B)(Dummy)
    \psline(Dummy)(FR)
    \psline(FR)(FR')
    \psline[arrows=-,linestyle=dotted](Focus)(FR)
    \psOutLine[arrows=-, linestyle=dotted](FR)(Focus){PBegin}
  \fi
  \end{pspicture}%
}\ignorespaces}
%
\def\mirrorDVGRay{\@ifnextchar[{\pst@mirrorDVGRay}{\pst@mirrorDVGRay[]}}%  Herbert Voss 2003/01/05
\def\pst@mirrorDVGRay[#1](#2)(#3)#4{{%
  \psset[pst-optic,pstricks]{#1}%
  \pnode(!%
    \psk@optic@mirrorHeight\space dup mul 16 div 
    \psk@optic@mirrorDepth\space div neg 0){Focus}
    \ifx\psk@optic@mirrorType\mirrorType % DVG or Spherical
	\pst@getcoor{#2}\pst@tempA
	\pst@getcoor{#3}\pst@tempB
	\pnode(!%
	  /A 2 \psk@optic@mirrorHeight\space div dup mul \psk@optic@mirrorDepth\space mul neg def
	  /XA \pst@tempA exch pop \pst@number\psyunit div neg def
	  /YA \pst@tempA pop \pst@number\psxunit div def
	  /XB \pst@tempB exch pop \pst@number\psyunit div neg def
	  /YB \pst@tempB pop \pst@number\psxunit div def
	  XB abs 0.001 lt YB abs 0.001 lt and { 0 0 }{
	    XB XA sub abs 0.01 lt 
	        {A XA dup mul mul XA neg}{
		/Xmax \psk@optic@mirrorHeight\space 2 div def
		/m YB YA sub XB XA sub div def
		/m2a m A div 2 div def
		/Root m2a dup mul m XA mul YA sub A div sub Sqrt def
		/X1 m2a Root add def
		/X2 m2a Root sub def
		/X XB X1 sub abs XB X2 sub abs lt 
	    	    {X1}{X2} ifelse def
		/Y A X dup mul mul def
		X abs Xmax lt 
	    	    {Y X neg}
	    	    {A Xmax dup mul mul Xmax neg} ifelse
	    } ifelse
	} ifelse){#4}
    % #4 is the point on the mirror
    \pst@getcoor{#2}\pst@tempC% the starting point
    \pst@getcoor{#4}\pst@tempA% the point on the mirror
    \pst@getcoor{Focus}\pst@tempf% the point on the mirror
    \pnode(!
	/XA \pst@tempA exch pop \pst@number\psyunit div neg def
	/YA \pst@tempA pop \pst@number\psxunit div def
	/XC \pst@tempC exch pop \pst@number\psyunit div neg def
	/YC \pst@tempC pop \pst@number\psxunit div def
	XA abs 0.001 lt YA abs 0.001 lt and 
	    {YC XC}{
	    /YF \pst@tempf pop \pst@number\psxunit div def
	    /DY YA YC sub def
	    /DX XA XC sub def 
	    /Alpha A XA mul 0.5 atan def
	    /Delta 180 DY DX atan sub Alpha 2 mul add def 
	    Delta round cvi 90 mod 0 eq {YC XA neg}{
		/m DX abs 0.01 lt 
		    {YA YF sub XA div}
		    {Delta sin Delta cos div} ifelse def
		/X \psk@optic@length\space Delta cos mul neg XA add def
		/Y \psk@optic@length\space Delta sin mul neg YA add def
		Y X neg
	    } ifelse
	} ifelse){#4'}% second point on the mirror
    \else
%--------------- A Spherical Mirror -----------------
      \ABinterSPHLens(#2)(#3)(Center){tempRef0}
    	 \pst@getcoor{tempRef0}\pst@tempA
    	 \pst@getcoor{tempRef0'}\pst@tempB
      \pnode(!%
        \pst@tempA /Y1 exch \pst@number\psyunit div def
        /X1 exch \pst@number\psxunit div def
        \pst@tempB /Y2 exch \pst@number\psyunit div def
        /X2 exch \pst@number\psxunit div def
        X1 X2 gt {X1 Y1}{X2 Y2}ifelse ){#4}
      \reflectionRay[mirrorType=SPH](#2)(#4){tempRef1}
	\pnode(tempRef1){#4'}
    \fi
    \ifPst@drawing
	\psline[#1](#2)(#4)(#4')
    \fi
}\ignorespaces}
%

% HEadlight Herbert <voss@perce.de> 2003/01/23
%
\def\beamLight{\@ifnextchar[{\pst@beamLight}{\pst@beamLight[]}}
\def\pst@beamLight[#1]{{%
	\psset[pst-optic]{xLeft=-5,xRight=5,yBottom=-5,yTop=5,%
		drawing=false}% 	the defaults
	\psset[pst-optic,pstricks]{#1}%
\begin{pspicture*}(\psk@optic@xLeft,\psk@optic@yBottom)(\psk@optic@xRight,\psk@optic@yTop)
	\rput(0,0){%
		\mirrorCVG[#1]%
	}
	\psline[linewidth=0.1cm]%
		(!\psk@optic@mirrorDepth\space \psk@optic@mirrorHeight\space 2 div neg)%
		(!\psk@optic@mirrorDepth\space \psk@optic@mirrorHeight\space 2 div)
	\psset{linewidth=0.75mm,fillstyle=solid}
	\psline(-1.1,1)(0.2,1)
	\psline(-1.1,-1)(0.2,-1)
	\pscurve(0.2,0.75)(1.6,1.5)(3,1)(3.5,0)(3,-1)(1.6,-1.5)(0.2,-0.75)
	\psframe(-1.1,-0.85)(0.2,0.85)
	\psframe(0.2,-0.3)(0.5,0.3)
	\psline(-1.1,-0.85)(-1.4,-0.6)(-1.4,0.6)(-1.1,0.85)
	\psline(0,0)(2.9,0)(2.9,0.5)(0.9,0.5)(0.9,0)%
	\psline(3.0,0)(3.0,-0.3)(2.5,-0.3)(2.2,0.15)(2,-0.15)%
		(1.8,0.15)(1.6,-0.15)(1.4,0.15)(1.2,-0.15)(1,0.15)%
	\psline[linecolor=black,linewidth=0.5pt,linestyle=dashed](-1.75,0)(10,0)
\end{pspicture*}%
}\ignorespaces}
%
%
%Telescope
%2 juillet 2001
%
\def\mirrorTwo{%
	\psframe[linestyle=none,%
		fillstyle=vlines,%
		hatchwidth=0.5\pslinewidth,%
		hatchsep=3\pslinewidth](-1,0)(1,0.2)
    \psline[linewidth=1.5\pslinewidth](-1,0)(1,0)%
}
%
\def\telescope{\@ifnextchar[{\pst@telescope}{\pst@telescope[]}}
\def\pst@telescope[#1]{{%
    \psset[pst-optic]{xLeft=-0.5,xRight=11,yBottom=-6,yTop=2}% the default
    \def\@tempa{#1}%
    \ifx\@tempa\@empty\else\psset[pst-optic,pstricks]{#1}\fi%
    \pstVerb{%
	/mirrorFocus \psk@optic@mirrorFocus\space def
	/Coeff mirrorFocus 4 mul def
	/mirrorTwoAngle \psk@optic@mirrorTwoAngle\space def
	/posMirrorTwo \psk@optic@posMirrorTwo\space def
    }%
%
\begin{pspicture*}(\psk@optic@xLeft,\psk@optic@yBottom)(\psk@optic@xRight,\psk@optic@yTop)
  \rput(0,0){%
    \mirrorCVG[%
	mirrorHeight=4,%
	mirrorWidth=0.25,%
	mirrorDepth=0.25,%
	drawing=false]%
  }
  \pnode(! \psk@optic@xLeft\space 0){xLeft}
  \pnode(! \psk@optic@xRight\space 0){xRight}
  \psline[linewidth=0.5\pslinewidth](11,0)
  \pnode(! 1.5 dup mul Coeff div 1.5){P1}
  \pnode(! 1.5 dup mul Coeff div 1.5 neg){P2}
  \pnode(! mirrorFocus 0){mirrorFocusNode}
  \pnode(! posMirrorTwo 1 mirrorTwoAngle cos mul sub
	1 mirrorTwoAngle sin mul){UpMirror2}
  \pnode(! posMirrorTwo 1 mirrorTwoAngle cos mul add
	1 mirrorTwoAngle sin mul neg){DownMirror2}
  \ABinterCD(P1)(mirrorFocusNode)(UpMirror2)(DownMirror2){Inter1}
  \ABinterCD(P2)(mirrorFocusNode)(UpMirror2)(DownMirror2){Inter2}
  \pnode(!%
	 \psk@optic@posMirrorTwo\space posMirrorTwo mirrorFocus sub){ocularFocusNode}
  {%
    \psset{linecolor=red}
    \Arrows[arrows=->,arrowsize=0.2](11,1.5)(P1)
    \Arrows[arrows=->,arrowsize=0.2](P1)(Inter1)
%
    \Arrows[arrows=->>,arrowsize=0.2](11,-1.5)(P2)
    \Arrows[arrows=->>,arrowsize=0.2](P2)(Inter2)
    \psline[linestyle=dashed](Inter2)(mirrorFocusNode)
    \pnode(! 5 \psk@optic@posMirrorTwo\space 2 sub neg){ocularLeft}
    \pnode(! 7 \psk@optic@posMirrorTwo\space 2 sub neg){ocularRight}
    \ABinterCD(Inter1)(ocularFocusNode)(ocularLeft)(ocularRight){FO1}
    \ABinterCD(Inter2)(ocularFocusNode)(ocularLeft)(ocularRight){FO2}
    \Arrows[arrows=->>,arrowsize=0.2,length=1](Inter2)(FO2)
    \psline(11,-1.5)(P2)(Inter2)(FO2)
    \Arrows[arrows=->,arrowsize=0.2](Inter1)(ocularFocusNode)
    \psline[linestyle=dashed](Inter1)(mirrorFocusNode)
    \psline(11,1.5)(P1)(Inter1)(FO1)
  }
  \rput{-\psk@optic@mirrorTwoAngle}(\psk@optic@posMirrorTwo,0){\mirrorTwo}
  \uput[90](mirrorFocusNode){$\mathrm{F_1}$}
  \uput[180](ocularFocusNode){$\mathrm{F_2}$}
  \rput{90}(!%
    \psk@optic@posMirrorTwo\space 
    \psk@optic@posMirrorTwo\space 2 sub neg){%
	\psscalebox{0.5 0.4}{\lens[lensWidth=0.4,lensGlass=true,drawing=false]}}
  \pnode(0,2){Aux1}
  \pnode(0,-2){Aux2}
  \Parallel[length=1](Aux1)(Aux2)(FO1){Eye1}
  \Parallel[length=1](Aux1)(Aux2)(FO2){Eye2}
  {%
    \psset{linecolor=red,arrowsize=0.2,length=0.7}
    \psline[linecolor=red](FO1)(Eye1)
    \psline[linecolor=red](FO2)(Eye2)
    \Arrows[arrows=->](FO1)(Eye1)
    \Arrows[arrows=->>](FO2)(Eye2)%
  }
  \rput{-90}(!%
    \psk@optic@posMirrorTwo\space 
    \psk@optic@posMirrorTwo\space neg){\psscalebox{0.6}{\eye}}
\end{pspicture*}%
}\ignorespaces}
%
%Images et réflexions sur un miroir plan
%(#1) coordonnées du point objet (XA,YA)
%(#2) coordonnées d'une extrémité du miroir (X1,Y1)
%(#3) coordonnées de l'autre extrémité du miroir (X2,Y2)
%{#4} nom de l'image A'
%
\def\planMirrorRay(#1)(#2)(#3)#4{{%
\pst@getcoor{#1}\pst@tempA
\pst@getcoor{#2}\pst@tempB
\pst@getcoor{#3}\pst@tempc
\pnode(!%
    \pst@tempA /YA exch \pst@number\psyunit div def
    /XA exch \pst@number\psxunit div def
    \pst@tempB /Y1 exch \pst@number\psyunit div def
    /X1 exch \pst@number\psxunit div def
    \pst@tempc /Y2 exch \pst@number\psyunit div def
    /X2 exch \pst@number\psxunit div def
    /Dx X2 X1 sub def
    /Dy Y2 Y1 sub def
    /xH XA Dx Dx mul mul
        X1 Dy Dy mul mul
        add
        YA Y1 sub Dx Dy mul mul
        add
        Dx Dx mul Dy Dy mul add
        div
    def
    /yH YA Dy Dy mul mul
        Y1 Dx Dx mul mul
        add
        XA X1 sub Dx Dy mul mul
        add
        Dx dup mul Dy dup mul add
        div
    def
    /xA' 2 xH mul XA sub def
    /yA' 2 yH mul YA sub def
    /D12 Dx Dx mul Dy Dy mul add Sqrt def
    xA' yA' moveto
    xH yH rlineto
    xA' yA'){#4}
}\ignorespaces}
%
% 2002/12/27
%
\def\symPlan(#1)(#2){\pst@killglue\pst@makebox{\symPlan@(#1)(#2)}}%
\def\symPlan@(#1)(#2){{%
    \pst@getcoor{#1}\pst@tempA
    \pst@getcoor{#2}\pst@tempB
    \leavevmode
    \hbox{%
	\pnode(!
	    \pst@tempA /Y1 exch def
	    /X1 exch def
	    \pst@tempB /Y2 exch def
	    /X2 exch def
	    /DX X2 X1 sub def
	    /DY Y2 Y1 sub def
	    /D12 DX dup mul DY dup mul add def
	    /ax 2 DX dup mul mul D12 div 1 sub def
	    /by 2 DX DY mul mul D12 div def
	    /cx by def
	    /dy 2 DY dup mul mul D12 div 1 sub def
	    /tx X1 DY dup mul mul
	    Y1 DX DY mul mul sub
	    2 mul
	    D12 div
	    def
	    /ty Y1 DX dup mul mul
	    X1 DX DY mul mul sub
	    2 mul
	    D12 div
	    def
	    X1 Y1){Factice}%
	\pst@Verb{
	    { [ax by cx dy tx ty] concat } tx@3Ddict begin TMChange end }%
	\box\pst@hbox
	\pst@Verb{ tx@3Ddict begin TMRestore end }}%
  }\ignorespaces}
%
% psrefractionRay[options](A)(B)(C)(D){rNoA}{rNoB}{E}
% (A)(B) the ray nodes   #2 #3
% (C)(D) the nodes of the other material  #4 #5 
% {rNoA}{rNoB} the refraction numbers (n1=#6,  n2=#7) 
% {E} the intermediate node of the ray and the material  (E=#8)
% {E'} the end node of the ray  (internal)
%
% Herbert Voss <voss@perce.de> 2003-01-26
%
\def\refractionRay{\@ifnextchar[{\pst@refractionRay}{\pst@refractionRay[]}}
\def\pst@refractionRay[#1](#2)(#3)(#4)(#5)#6#7#8{{%
    \psset[pst-optic,pstricks]{#1}%
    \pst@getcoor{#2}\pst@tempA
    \pst@getcoor{#3}\pst@tempB
    \pst@getcoor{#4}\pst@tempc
    \pst@getcoor{#5}\pst@tempd
    \ABinterCD(#2)(#3)(#4)(#5){#8}%
%\psset{linecolor=black}
%\qdisk(#8){2pt}
% #8 is the point on the material
    \pst@getcoor{#8}\pst@tempp
    \def\pst@optic@cIn{#6}	% refraction number 1
    \def\pst@optic@cOut{#7}	% refraction number 2
    \pnode(!
    /YA \pst@tempA exch pop \pst@number\psyunit div def
	/XA \pst@tempA pop \pst@number\psxunit div def
	/YB \pst@tempB exch pop \pst@number\psyunit div def
	/XB \pst@tempB pop \pst@number\psxunit div def
    /YC \pst@tempc exch pop \pst@number\psyunit div def
	/XC \pst@tempc pop \pst@number\psxunit div def
	/YD \pst@tempd exch pop \pst@number\psyunit div def
	/XD \pst@tempd pop \pst@number\psxunit div def
	/YP \pst@tempp exch pop \pst@number\psyunit div def
	/XP \pst@tempp pop \pst@number\psxunit div def
	/dY1 YP YA sub def
	/dX1 XP XA sub def
	/dY2 YD YC sub def
	/dX2 XD XC sub def
% the gradient of the material (if negativ then it must be the nominator)
% if = 0 then substract 180Â°
	/Gamma dY2 dX2 mul 0 ge {dY2 dX2}{dY2 abs neg dX2 abs} ifelse atan 
	  %dup 0 eq { 180 sub } if 
	  def 
% the perpendicular line is: 90Â°-Gamma
	/GammaStrich 90 Gamma sub def
% the angle of the incoming ray
	/AlphaStrich dY1 dX1 atan def
% the same relative to the material
	/Alpha 90 AlphaStrich sub Gamma add def
% the angle of the outgoing ray relative to the material
% the law of Snell: sin(Alpha)/sin(Beta) = n2/n1
% sin(Beta)>1 is a total reflection instead of a refraction
	/sinBeta \pst@optic@cIn\space \pst@optic@cOut\space div Alpha sin mul def
	sinBeta abs 1 le {
		/Root 1 sinBeta dup mul sub Sqrt def
		/Beta sinBeta Root atan def
	}{
		/Beta 180 Alpha sub def
	} ifelse
% the same absolute
	/BetaStrich 90 Gamma sub Beta add def 
% Determine the intermediate point
	XP BetaStrich cos sub
	YP BetaStrich sin add ){#8'}
%\qdisk(#8){5pt}
}\ignorespaces}
%
% Herbert Voss <voss@perce.de> 2003-02-10
%
% reflectionRay[options](A)(B){C}
% options: the type of
% (A)(B) the ray nodes
% {C} the intermediate node of the ray and the material
% {C'} the end node of the reflected ray
%
\def\reflectionRay{\@ifnextchar[{\pst@reflectionRay}{\pst@reflectionRay[]}}
\def\pst@reflectionRay[#1](#2)(#3)#4{{%
	\psset[pst-optic,pstricks]{#1}
	\pst@getcoor{#2}\pst@tempA% the starting point
	\pst@getcoor{#3}\pst@tempp% the point on the mirror
	\pst@getcoor{Center}\pst@tempc% the center/focus of the mirror
	\ifx\psk@optic@mirrorType\mirrorType%  Parabolic
	\else% Spherical
  \pnode(!%
        /XA \pst@tempA exch pop \pst@number\psyunit div neg def
        /YA \pst@tempA pop \pst@number\psxunit div def
        /XC \pst@tempc exch pop \pst@number\psyunit div neg def
        /YC \pst@tempc pop \pst@number\psxunit div def
        /XP \pst@tempp exch pop \pst@number\psyunit div neg def
        /YP \pst@tempp pop \pst@number\psxunit div def
        /dY1 YA YP sub def
        /dX1 XA XP sub def
	   /signum YP 0 lt {-1}{1}ifelse def
% the gradient of the point. radius must be defined
        /root radius dup mul XP dup mul sub Sqrt def
        /Gamma XP signum mul root atan 180 sub def
% the angle of the incoming ray
        /AlphaStrich dY1 dX1 atan 180 sub def
% the same relative to the material
        /Alpha 90 AlphaStrich sub Gamma add def
% the angle of the outgoing ray absolute
%       /BetaStrich Alpha 2 mul AlphaStrich sub def
        /BetaStrich Gamma Alpha add 90 sub def
% Determine the intermediate point
        YP BetaStrich sin add XP BetaStrich cos add neg){#4}
	\fi
}\ignorespaces}
%
% Prism stuff initiated by Manuel 2006-07-26
%
\define@key[psset]{pst-optic}{AnglePrism}{\edef\psk@Prism@AnglePrism{#1}}
\define@key[psset]{pst-optic}{AnglePlan1}{\edef\psk@Prism@AnglePlanOne{#1}}
\define@key[psset]{pst-optic}{AnglePlan2}{\edef\psk@Prism@AnglePlanTwo{#1}}
\define@key[psset]{pst-optic}{lambda}{\edef\psk@Prism@Lambda{#1}}
\define@key[psset]{pst-optic}{k}{\edef\psk@Prism@k{#1}}
\define@boolkey[psset]{pst-optic}[Pst@Prism@]{notations}[true]{}
%
\psset[pst-optic]{AnglePrism=60,AnglePlan1=25,AnglePlan2=55,k=1,lambda=632.8,notations=true}
%
\def\psprism{\pst@object{psprism}}
\def\psprism@i{%
  \begin@SpecialObj
  \ifPst@Prism@notations
    \psline{->}(0,8)
    \uput[90](0,8){$y$}
    \psline{->}(-6,0)(6,0)
    \uput[0](6,0){$x$}
  \fi
  \pnode(0,0){O}
  \pnode(!
    /AnglePrism \psk@Prism@AnglePrism\space 2 div def
    /AnglePlan1 \psk@Prism@AnglePlanOne\space def
    /AnglePlan2 \psk@Prism@AnglePlanTwo\space def
    /lambda \psk@Prism@Lambda\space def
  % le point C1 sur la droite 1
    /C1x -6 def
    /C1y 6 def
  % le point C2 sur la droite 2
    /C2x 7 def
    /C2y 5 def
  % donne la distance C1E
    /k \psk@Prism@k\space def
  %
    /g1x AnglePrism sin neg def % -sin(A/2)
    /g1y AnglePrism cos def     %  cos(A/2)
    /u1x AnglePlan1 sin neg def
    /u1y AnglePlan1 cos neg def
  % le point E émetteur
    /E1x C1x k u1x mul add def
    /E1y C1y k u1y mul add def
    %
    /n1x AnglePlan1 cos def
    /n1y AnglePlan1 sin neg def
    /Lambda {E1x g1y mul E1y g1x mul neg add
             n1y g1x mul neg n1x g1y mul add
             div neg} bind def
  % point I1
    /i1x {E1x Lambda n1x mul add} bind def
    /i1y {E1y Lambda n1y mul add} bind def
    0 0){Stockage_parametres_prism}
  \pspolygon[fillstyle=gradient,gradbegin=cyan,gradend=white,gradangle=60,gradmidpoint=0.5](O)%
                                (! 7 90 AnglePrism add cos mul 7 90 AnglePrism add sin mul)
                                (! 7 90 AnglePrism sub cos mul 7 90 AnglePrism sub sin mul)
  \pnode(!
  % Les datas
  % Sellmeier's
  % glass sf15 : verre flint
  % n=Sqrt(1+B1*L^2/(l^2-C1)+B2*L^2/(l^2-C2)+B3*L^2/(l^2-C3))
  %  Cauchy :  /N {1.606 6545 1 mul lambda dup mul div add} bind def
    /L2 {lambda 1e-3 mul dup mul} bind def % en micromètres
    /N {1
        1.539259 L2 mul L2 0.011931 sub div
         add
         0.247621 L2 mul L2 0.055608 sub div
         add
         1.038164 L2 mul L2 116.416755 sub div
         add
         Sqrt} bind def
    /alpha1 AnglePlan1 AnglePrism add def
    /sinB1 alpha1 sin N div def
    /B1 sinB1 arcsin def
    /Delta1 AnglePrism B1 sub def
  %%%
    /g2x AnglePrism sin def
    /g2y AnglePrism cos def
    /d12x Delta1 cos def % d12x
    /d12y Delta1 sin def % d12y
    /Lambda2 {i1x g2y mul i1y g2x mul sub
            d12y g2x mul d12x g2y mul sub
            div} bind def
  % point I2
    /i2x {i1x Lambda2 d12x mul add} bind def
    /i2y {i1y Lambda2 d12y mul add} bind def
  %
    /B2  AnglePrism 2 mul B1 sub def
    /sinA2 N B2 sin mul def
    /alpha2 sinA2 asin def
    /u2x AnglePlan2 sin def
    /u2y AnglePlan2 cos neg def
    /Delta2 alpha2 AnglePrism sub def
    /d2x Delta2 cos def
    /d2y Delta2 sin def
    /DELTA u2x d2y mul neg u2y d2x mul add def
    /DELTA_X i2x C2x sub d2y mul neg
             i2y C2y sub d2x mul add def
    /DELTA_Y u2x i2y C2y sub mul neg
             u2y i2x C2x sub mul add def
    /MU DELTA_X DELTA div def
    /LAMBDA3 DELTA_Y DELTA div def
  % le point R2
    /r2x C2x MU u2x mul add def
    /r2y C2y MU u2y mul add def
    /a_i {AnglePlan1 neg} bind def
    /a_r {alpha2 AnglePrism sub} bind def
    /tan_i {a_i tan} bind def
    /tan_r {a_r tan} bind def
    0 0){factice}
  \pnode(! C1x C1y){C1}
  \pnode(! C2x C2y){C2}
  \pnode(! E1x E1y){E1}
  \pnode(! i1x i1y){P1}
  \pnode(! i2x i2y){I2}
  \pnode(! r2x r2y){R2}
  \pnode(! /bQ {i1y i1x AnglePrism tan mul sub} bind def
         /bQ' {i2y i2x AnglePrism tan mul add} bind def
         /xQ {bQ' bQ sub 2 div AnglePrism tan div} bind def
         /yQ {bQ bQ' add 2 div} bind def
         xQ yQ){Q}
  \pnode(! /bI {i1y i1x tan_i mul sub} bind def
         /bI'{i2y i2x tan_r mul sub} bind def
         /xI {bI bI' sub tan_r tan_i sub div} bind def
         /yI {xI tan_i mul bI add} bind def
         xI yI){I}
  \pcline[linestyle=dashed,nodesepB=-2](P1)(I)
  \pcline[linestyle=dashed,nodesepB=-2](I2)(I)
  \pcline[linestyle=dashed,nodesepB=-1,nodesepA=-2](P1)(Q)
  \pcline[linestyle=dashed,nodesepB=-1,nodesepA=-2](I2)(Q)
  \rput(P1){%
    \rput{30}(0,0){\psframe*(0,0)(0.2,0.2)}
    \psarc{<-}(0,0){0.8}{!180 AnglePrism add alpha1 sub}{!180 AnglePrism add}
    \uput{1}[! 180 AnglePrism add alpha1 2 div sub](0,0){$i_1$}
    \psarc[linecolor=blue]{<-}(0,0){1}{!AnglePrism B1 sub}{!AnglePrism}
    \uput{1.2}[! AnglePrism B1 2 div sub](0,0){$r_1$}
    \uput{0.4}[90](0,0){$I_1$}}
  \rput(I2){%
    \rput{60}(0,0){\psframe*(0,0)(0.2,0.2)}
    \psarc[linecolor=blue]{->}(0,0){0.8}{! AnglePrism neg 180 add}{!AnglePrism neg 180 add B2 add}
    \uput{1}[!AnglePrism neg 180 add B2 2 div add](0,0){$r_2$}
    \psarc{->}(0,0){1}{! AnglePrism neg}{!alpha2 AnglePrism sub}
    \uput{1.2}[!alpha2 2 div AnglePrism sub](0,0){$i_2$}
    \uput{0.4}[90](0,0){$I_2$}}
  \psline[linewidth=\psk@optic@rayWidth,linecolor={[wave]{\psk@Prism@Lambda}},arrowscale=2]{->}(P1)(I2)(R2)
  \psline[linewidth=\psk@optic@rayWidth,linecolor={[wave]{\psk@Prism@Lambda}}](E1)(P1)
  \psline[linewidth=\psk@optic@rayWidth,linecolor={[wave]{\psk@Prism@Lambda}},arrowscale=2]{->}(E1)(!i1x E1x add 2 div i1y E1y add 2 div)
  \psarc(0,0){0.8}{!90 AnglePrism sub}{!90 AnglePrism add}
  \uput[90](0,0.8){$\widehat{A}$}
  \psdot[dotstyle=o](O)
  \psdot[dotstyle=o](I)
  \psdot[dotstyle=o](Q)
  \rput(I){\psarc{->}(0,0){1}{!a_i}{!a_r}
         \uput{1.1}[!a_i a_r add 2 div](0,0){$\widehat{D}$}}
  \ifPst@Prism@notations 
    \pcline[nodesepB=-2,nodesepA=-2](C1)(E1)
    \uput[180](C1){$C_1$}
    \uput[180](E1){$E_1$}
    %
    \pcline[nodesepB=-2,nodesepA=-2](C2)(R2)
    \uput[-90](C2){$C_2$}
    \uput[180](R2){$R_2$}
    \rput(C1){\psline(0,2)
      \psarc(0,0){1}{! 90 AnglePlan1 sub}{90}
      \uput{1.1}[!90 AnglePlan1 2 div sub](0,0){$\rho_1$}
      \psline[arrowinset=0,linewidth=2\pslinewidth]{->}(! 
        90 AnglePlan1 sub cos neg 90 AnglePlan1 sub sin neg)
      \uput[0](! 90 AnglePlan1 sub cos neg 90 AnglePlan1 sub sin neg){$\overrightarrow{u}_1$}
      \psline[arrowinset=0,linewidth=2\pslinewidth]{->}(! AnglePlan1 neg cos AnglePlan1 neg sin)
      \uput[90](! AnglePlan1 neg cos AnglePlan1 neg sin){$\overrightarrow{n}_1$}}
    \rput(C2){\psline(0,2)
      \psarc(0,0){1}{90}{! 90 AnglePlan2 add}
      \uput{1.1}[!90 AnglePlan2 2 div add](0,0){$\rho_2$}
      \psline[arrowinset=0,linewidth=2\pslinewidth]{->}(! AnglePlan2 cos AnglePlan2 sin)
      \uput[! AnglePlan2](! AnglePlan2 cos AnglePlan2 sin){$\overrightarrow{n}_2$}
      \psline[arrowinset=0,linewidth=2\pslinewidth]{->}(! 90 AnglePlan2 add cos 90 AnglePlan2 add sin)
      \uput[-90](! 90 AnglePlan2 add cos 90 AnglePlan2 add sin){$\overrightarrow{u}_2$}}
    \psdot[dotstyle=o](C1)
    \psdot[dotstyle=o,linecolor={[wave]{\psk@Prism@Lambda}}](E1)
    \psdot[dotstyle=o](C2)
    \psdot[dotstyle=o](R2)
  \fi%
  \end@SpecialObj%
}
%
%% Commande \psprismColor
\def\psprismColor{\pst@object{psprismColor}}
\def\psprismColor@i{%
  \begin@SpecialObj
  \pnode(0,0){O}
  \pnode(!
    /AnglePrism \psk@Prism@AnglePrism\space 2 div def
    /AnglePlan1 \psk@Prism@AnglePlanOne\space def
    /AnglePlan2 \psk@Prism@AnglePlanTwo\space def
    % le point C1 sur la droite 1
    /C1x -8 def
    /C1y 7 def
    % le point C2 sur la droite 2
    /C2x 11 def
    /C2y 5 def
    % donne la distance C1E1
    /k \psk@Prism@k\space def
    %
    /g1x AnglePrism sin neg def % -sin(A/2)
    /g1y AnglePrism cos def     %  cos(A/2)
    /u1x AnglePlan1 sin neg def
    /u1y AnglePlan1 cos neg def
    % le point E émetteur
    /E1x C1x k u1x mul add def
    /E1y C1y k u1y mul add def
    %
    /n1x AnglePlan1 cos def
    /n1y AnglePlan1 sin neg def
    /Lambda {E1x g1y mul E1y g1x mul neg add
             n1y g1x mul neg n1x g1y mul add
             div neg} bind def
    % point I1
    /i1x {E1x Lambda n1x mul add} bind def
    /i1y {E1y Lambda n1y mul add} bind def
    0 0){Stockage_parametres_prism}
    \pspolygon[fillstyle=gradient,gradbegin=cyan,gradend=white,gradangle=60,gradmidpoint=0.5](O)%
        (! 7 90 AnglePrism add cos mul 7 90 AnglePrism add sin mul)
        (! 7 90 AnglePrism sub cos mul 7 90 AnglePrism sub sin mul)
    \multido{\iLAMBDA=400+5}{80}{%
      \pstVerb{/lambda \iLAMBDA\space def}%
      \definecolor{prism}{wave}{\iLAMBDA}%
      \pnode(!
        % Les datas
        % Sellmeier's
        % glass sf15 : verre flint lourd
        % n=Sqrt(1+B1*L^2/(l^2-C1)+B2*L^2/(l^2-C2)+B3*L^2/(l^2-C3))
        % Cauchy : /N {1.606 6545 1 mul lambda dup mul div add} bind def
        /L2 {lambda 1e-3 mul dup mul} bind def
        /N {1
          1.539259 L2 mul L2 0.011931 sub div add
          0.247621 L2 mul L2 0.055608 sub div add
          1.038164 L2 mul L2 116.416755 sub div add
          Sqrt} bind def
        /alpha1 AnglePlan1 AnglePrism add def
        /sinB1 alpha1 sin N div def
        /B1 sinB1 asin def
        /Delta1 AnglePrism B1 sub def
        %%%
        /g2x AnglePrism sin def
        /g2y AnglePrism cos def
        /d12x Delta1 cos def % d12x
        /d12y Delta1 sin def % d12y
        /Lambda2 {i1x g2y mul i1y g2x mul sub d12y g2x mul d12x g2y mul sub div} bind def
        % point I2
        /i2x {i1x Lambda2 d12x mul add} bind def
        /i2y {i1y Lambda2 d12y mul add} bind def
        %
    /B2 AnglePrism 2 mul B1 sub def
    /sinA2 N B2 sin mul def
    /alpha2 sinA2 asin def
    /u2x AnglePlan2 sin def
    /u2y AnglePlan2 cos neg def
    /Delta2 alpha2 AnglePrism sub def
    /d2x Delta2 cos def
    /d2y Delta2 sin def
    /s2x i2x C2x sub def
    /s2y i2y C2y sub def
    /dA d2x u2y mul d2y u2x mul sub def
    /dM d2x s2y mul d2y s2x mul sub def
% le point R2
    /r2x C2x dM dA div u2x mul add def
    /r2y C2y dM dA div u2y mul add def
   0 0){factice}
  \pnode(! C1x C1y){C1}
  \pnode(! C2x C2y){C2}
  \pnode(! E1x E1y){E1}
  \pnode(! i1x i1y){I1}
  \pnode(! i2x i2y){I2}
  \pnode(! r2x r2y){R2}
  \psline[linewidth=\psk@optic@rayWidth,linecolor=prism](I1)(I2)(R2)}
  \psline[linewidth=\psk@optic@rayWidth,linecolor=\psk@optic@rayColor,linewidth=0.5mm](E1)(I1)
  \psline[linewidth=\psk@optic@rayWidth,linecolor=\psk@optic@rayColor,linewidth=0.5mm,arrowscale=2]{->}(E1)(!i1x E1x add 2 div i1y E1y add 2 div)
  \end@SpecialObj%
}
%
%
\def\resetOpticOptions{%		hv 2006-07-20
  \newpsstyle{opticalAxis}{linewidth=0.5pt,linecolor=black,linestyle=solid}
  \psset[pst-optic]{%
  lensGlass=true,drawing=true,lensTwo,rightRay,onlyrays=false,
  xLeft=-7.5,xRight=7.5,yBottom=-3.0,yTop=3.0,
  lensType=CVG,lensColor=lightgray,lensWidth=0.5,lensDepth=1,
  lensHeight=5,lensScale=1,lensArrowSize=0.2,lensArrowInset=0.5,
  mirrorType=CVG,mirrorDepth=1,mirrorHeight=5,mirrorWidth=0.25,
  mirrorFocus=8,mirrorTwoAngle=45,posMirrorTwo=6,mirrorColor=lightgray,
  refractA=1,refractB=1.41,
  XO=0,YO=0,OA=-3,posStart=0,length=2,focus=2,AB=1,arrowOffset=0,
  nameO=O,spotO=225,nameAi=A',spotAi=90,nameBi=B',spotBi=270,
  nameFi=F',spotFi=270,
  rayColor=red,%
  AnglePrism=60,AnglePlan1=25,AnglePlan2=55,k=1,lambda=632.8,notations=true,
  rayWidth=\pslinewidth}%
%  \gdef\mirrorType{CVG}%
%  \gdef\lensTypeCVG{CVG}%
}
\catcode`\@=\PstAtCode\relax
%
%% END: pst-optic.tex
\endinput
