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: ptriprojn.m
    path of file: ./repos/spm/external/fieldtrip/plotting/private
    
    the code of the file until where you have to start completion: function [proj, dist] = ptriprojn(v1, v2, v3, r, flag)

% PTRIPROJN projects a point onto the plane going through a set of
% triangles
%
% Use as
%   [proj, dist] = ptriprojn(v1, v2, v3, r, flag)
% where v1, v2 and v3 are Nx3 matrices with vertex positions of the triangles, 
% and r is the point that is projected onto the planes spanned by the vertices
% This is a vectorized version of Robert's ptriproj function and is

    
function [proj, dist] = ptriprojn(v1, v2, v3, r, flag)

% PTRIPROJN projects a point onto the plane going through a set of
% triangles
%
% Use as
%   [proj, dist] = ptriprojn(v1, v2, v3, r, flag)
% where v1, v2 and v3 are Nx3 matrices with vertex positions of the triangles, 
% and r is the point that is projected onto the planes spanned by the vertices
% This is a vectorized version of Robert's ptriproj function and is
% generally faster than a for-loop around the mex-file.
%
% the optional flag can be:
%   0 (default)  project the point anywhere on the complete plane
%   1            project the point within or on the edge of the triangle

if nargin<5
  flag = false;
end