function [ pupilPosition, pupilHeight] = computeParaxialEntrancePupil(refIndex,thick,curv,stopIndex, realStopHeight)
%comcomputeEntrancePupil: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;
y2= realStopHeight;
u2= 0.0002;

[yo1,uo1]=yniTrace(y1,u1,stopIndex,1, refIndex,thick,curv); 
[yo2,uo2]=yniTrace(y2,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
pupilPosition = (yo2-yo1)/(tan (uo1) - tan (uo2));
pupilHeight = yo1+pupilPosition*tan(uo1);
end