You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: calcRetinaCartTo2DPol.m
    path of file: ./repos/gkaModelEye/model/calc
    
    the code of the file until where you have to start completion: function [theta,eccentricity] = calcRetinaCartTo2DPol(eye,X,P)
% Returns 2D polar coordinate for a point on the retinal surface
%
% Syntax:
%  [theta,eccentricity] = calcRetinaCartTo2DPol(eye,X,P)
%
% Description
%   We define a retinal polar coordinate space with angle theta as:
%         0 - nasal retinal meridian
%        90 - superior retinal meridian
%       180 - temporal retinal meridian
%       270 - inferior retinal meridian
%   and eccentricity in geodesic mm. By default, the origin of this space
%   is the fovea. This accomplishes a 2D embedding of the 3D retinal
%   surface.
%
%   This function returns the 2D, polar coordinate for a 3D, Cartesian
%   coordinate on the retinal surface.
%
% Inputs:
%   eye                   - Structure. SEE: modelEyeParameters
%   X                     - 3x1 vector that is a location on the retinal
%                           surface.
%   P                     - 3x1 vector that provides a coordinate on the
%                           retinal surface that is the origin of the 2D
%                           polar space. If undefined, the foveal
%                           coordinate in the eye structure is used.
%
% Outputs:
%   theta                 - Scalar, in degrees, in the domain 0-360.
%   eccentricity          - Scalar, in mm.
%
% Examples:
%{
    % Test of invertability of the conversion
    eye = modelEyeParameters();
    initialTheta = 225; initialEccen = 1.75;
    X = calcRetina2DPolToCart(eye,initialTheta,initialEccen);
    [theta,eccentricity] = calcRetinaCartTo2DPol(eye,X);
    assert(abs(initialEccen-eccentricity)<1e-2);
    assert(abs(initialTheta-theta)<1e-2);
%}

    
function [theta,eccentricity] = calcRetinaCartTo2DPol(eye,X,P)
% Returns 2D polar coordinate for a point on the retinal surface
%
% Syntax:
%  [theta,eccentricity] = calcRetinaCartTo2DPol(eye,X,P)
%
% Description
%   We define a retinal polar coordinate space with angle theta as:
%         0 - nasal retinal meridian
%        90 - superior retinal meridian
%       180 - temporal retinal meridian
%       270 - inferior retinal meridian
%   and eccentricity in geodesic mm. By default, the origin of this space
%   is the fovea. This accomplishes a 2D embedding of the 3D retinal
%   surface.
%
%   This function returns the 2D, polar coordinate for a 3D, Cartesian
%   coordinate on the retinal surface.
%
% Inputs:
%   eye                   - Structure. SEE: modelEyeParameters
%   X                     - 3x1 vector that is a location on the retinal
%                           surface.
%   P                     - 3x1 vector that provides a coordinate on the
%                           retinal surface that is the origin of the 2D
%                           polar space. If undefined, the foveal
%                           coordinate in the eye structure is used.
%
% Outputs:
%   theta                 - Scalar, in degrees, in the domain 0-360.
%   eccentricity          - Scalar, in mm.
%
% Examples:
%{
    % Test of invertability of the conversion
    eye = modelEyeParameters();
    initialTheta = 225; initialEccen = 1.75;
    X = calcRetina2DPolToCart(eye,initialTheta,initialEccen);
    [theta,eccentricity] = calcRetinaCartTo2DPol(eye,X);
    assert(abs(initialEccen-eccentricity)<1e-2);
    assert(abs(initialTheta-theta)<1e-2);
%}

arguments
    eye (1,1) {isstruct}
    X (3,1) {mustBeNumeric}
    P (3,1) {mustBeNumeric} = eye.landmarks.fovea.coords'
end