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: findball.m
    path of file: ./repos/mesh2d/aabb-tree
    
    the code of the file until where you have to start completion: function [bp,bj,tr] = findball(bb,pp,varargin)
%FINDBALL spatial queries for collections of d-balls.
%   [BP,BI] = FINDBALL(BB,PI) finds the set of d-dim. balls
%   that intersect with a given spatial query. Balls are sp-
%   ecified as a set of centres BB(:,1:ND) and (squared)
%   radii BB(:,ND+1), where ND is the number of dimensions.
%
%   A set of intersecting balls is returned for each query
%   point in PI, such that the II-th point is associated
%   with the balls BI(BP(II,1):BP(II,2)). Unenclosed points
%   have BP(II,1) == 0.
%
%   [BP,BI,TR] = FINDBALL(BB,PI) additionally returns the
%   supporting aabb-tree used internally to compute the que-
%   ry. If the underlying collection BB is static, the tree
%   TR may be passed to subsequent calls, via [BP,BI,TR] =
%   FINDBALL(BB,PI,TR). This syntax may lead to improved pe-
%   rformance, especially when the number of balls is large
%   w.r.t. the number of query points. Note that in such ca-
%   ses the distribution of underlying balls is NOT permitt-
%   ed to change between calls, or erroneous results may be
%   returned. Additional parameters used to control the cre-
%   ation of the underlying aabb-tree may also be passed via
%   [...] = FINDBALL(BB,PI,TR,OP). See MAKETREE for additio-
%   nal information.
%

    
function [bp,bj,tr] = findball(bb,pp,varargin)
%FINDBALL spatial queries for collections of d-balls.
%   [BP,BI] = FINDBALL(BB,PI) finds the set of d-dim. balls
%   that intersect with a given spatial query. Balls are sp-
%   ecified as a set of centres BB(:,1:ND) and (squared)
%   radii BB(:,ND+1), where ND is the number of dimensions.
%
%   A set of intersecting balls is returned for each query
%   point in PI, such that the II-th point is associated
%   with the balls BI(BP(II,1):BP(II,2)). Unenclosed points
%   have BP(II,1) == 0.
%
%   [BP,BI,TR] = FINDBALL(BB,PI) additionally returns the
%   supporting aabb-tree used internally to compute the que-
%   ry. If the underlying collection BB is static, the tree
%   TR may be passed to subsequent calls, via [BP,BI,TR] =
%   FINDBALL(BB,PI,TR). This syntax may lead to improved pe-
%   rformance, especially when the number of balls is large
%   w.r.t. the number of query points. Note that in such ca-
%   ses the distribution of underlying balls is NOT permitt-
%   ed to change between calls, or erroneous results may be
%   returned. Additional parameters used to control the cre-
%   ation of the underlying aabb-tree may also be passed via
%   [...] = FINDBALL(BB,PI,TR,OP). See MAKETREE for additio-
%   nal information.
%
%   See also MAKETREE, FINDTRIA

% Please see the following for additional information:
%
%   Darren Engwirda, "Locally-optimal Delaunay-refinement &
%   optimisation-based mesh generation". Ph.D. Thesis, Scho-
%   ol of Mathematics and Statistics, Univ. of Sydney, 2014:
%   http://hdl.handle.net/2123/13148

%   Darren Engwirda : 2017 --
%   Email           : d.engwirda@gmail.com
%   Last updated    : 27/04/2017

    bp = []; bj = []; tr = []; op = [];

%---------------------------------------------- basic checks
    if (nargin < +2 || nargin > +4)
        error('findball:incorrectNumInputs', ...
            'Incorrect number of inputs.');
    end