function XYproj = ProjectPointsOntoConicByEberlyOrig(XY,ParA) % % Original Eberly's method % Projecting a given set of points onto a quadratic curve (conic) % The conic is defined by quadratic equation % Ax^2 + 2Bxy + Cy^2 + 2Dx + 2Ey + F = 0 % Input: ParA = (A,B,C,D,E,F)' is the column vector of the parameters of the conic % XY(n,2) is the array of coordinates of n points x(i)=XY(i,1), y(i)=XY(i,2) % Output: XYproj is the array of coordinates of projections % The algorithm consists of several steps: % 1. Determine the type of conic and find its geometric parameters % 2. Transform the conic to its canonical coordinate system % 3. Find the projections in the canonical coordinates % 4. Transform the projected points back to the original coordinates % 5. (optional) Adjust the coordinates of the projected points % Step 1 is done in the function "AtoG" % Steps 2,3,4 are done in the conic-specific functions % "ProjectPointsOntoEllipse", "ProjectPointsOntoHyperbola", etc. % This module "coordinates" the procedure % Nikolai Chernov, February 2012 % First, determine the type of conic (given by its code) % and convert its algebraic parameters ParA to its geometric parameters ParG [ParG,code] = AtoG(ParA); % ParG is vector of geometric parameters % if code>2, then it is either imaginary or degenerate conic if code > 3 fprintf(1,' Imaginary or degenerate conic (code=%d)\n',code); return; end if (code==1) % conic is an ellipse XYproj = ProjectPointsOntoEllipse(XY,ParG); end if (code==2) % conic is a hyperbola XYproj = ProjectPointsOntoHyperbola(XY,ParG); end if (code==3) % conic is a parabola XYproj = ProjectPointsOntoParabola(XY,ParG); end end % ProjectPointsOntoConicByEberlyOrig