function [ pupilPosition, pupilHeight] = computeMeridionalEntrancePupil(refIndex,thick,curv,stopIndex, realStopHeight)
%comcomputeMeridionalEntrancePupil:computes position and size of enterance pupil

%Input
% refIndex,thick,curv : arrays of n,t of medium following and C of each
% surface from object to image surface
% stostopIndex, storealStopHeight: index number and the real height of the stop surface

%Output 
%pupilPosition, pupilHeight

%trace two rays from the tip of the stop back to the object surface
y1= realStopHeight;
U1= 0;
Q1= y1*cos(U1);

y2= realStopHeight;
U2= 0.2;
Q2= y2*cos(U2);

[Qo1,Uo1]=QUTrace(Q1,U1,stopIndex,1, refIndex,thick,curv); 
[Qo2,Uo2]=QUTrace(Q2,U2,stopIndex,1, refIndex,thick,curv);

%find the intersection point of the two ray. That is the image of the stop and so enterance pupil
yo1=Qo1/cos(Uo1);
yo2=Qo2/cos(Uo2);
pupilPosition = (yo2-yo1)/(tan (uo1) - tan (uo2));
pupilHeight = yo1+pupilPosition*tan(uo1);
end