
%real system
refIndex=[1 1.5 1 1];
thick=[20 15 64.6202 0];
curv=[0 0.02 -0.02 0]; 

%trial data
%refIndex=[1 2 1];
%thick = [2 2 2]; 
%curv = [0 0.2 0];


fieldPoint = 1;
stopIndex = 2; 
realStopHeight=3

Qi = -0.123456;
Ui = 0.023456;
initialSurf  = 1; finalSurf = 3;

[Qf Uf] = QUTrace(Qi,Ui,initialSurf,finalSurf, refIndex,thick,curv);

[Q1 U1] = QUTrace(Qf,Uf,finalSurf, initialSurf,refIndex,thick,curv);




%[ yc uc ] = computeParaxialCheifRay(fieldPoint, refIndex,thick,curv,stopIndex,delU,delY)
[ pupilPosition, pupilHeight] = computeMeridionalEntrancePupil(refIndex,thick,curv,stopIndex, realStopHeight); 
[ pupilPositionParax, pupilHeightParax] = computeParaxialEntrancePupil(refIndex,thick,curv,stopIndex, realStopHeight)

[ ymParax umParax ] = computeMariginalRay(pupilPositionParax, pupilHeightParax,thick(1))
[ QmMerid UmMerid] = computeMariginalRay(pupilPosition, pupilHeight,thick(1)) ;  


fieldHeight = 0.02;


[ ycParax ucParax ] = computeCheifRay(fieldHeight,pupilPositionParax) ;
[ QcMerid UcMerid ] = computeCheifRay(fieldHeight,pupilPosition);

%check the mariginal and cheif ray at the stop.
[yfmParxa ufmParax] = yniTrace(ymParax,umParax ,initialSurf,stopIndex, refIndex,thick,curv) 
[yfcParax ufcParax] = yniTrace(ycParax,ucParax ,initialSurf,stopIndex, refIndex,thick,curv) ; 

[QfmMerid UfmMerid] = QUTrace(QmMerid,UmMerid ,initialSurf,stopIndex, refIndex,thick,curv) ;
[QfcMerid UfcMerid] = QUTrace(QcMerid,UcMerid ,initialSurf,stopIndex, refIndex,thick,curv);
 




