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: clipConvexPolygon3dHP.m
    path of file: ./repos/matGeom/matGeom/deprecated/geom3d
    
    the code of the file until where you have to start completion: function poly2 = clipConvexPolygon3dHP(poly, plane)
%CLIPCONVEXPOLYGON3DHP Clip a convex 3D polygon with Half-space.

    
function poly2 = clipConvexPolygon3dHP(poly, plane)
%CLIPCONVEXPOLYGON3DHP Clip a convex 3D polygon with Half-space.
%
%   POLY2 = clipConvexPolygon3dHP(POLY, PLANE)
%   POLY is a N-by-3 array of points, and PLANE is given as:
%   [x0 y0 z0 dx1 dy1 dz1 dx2 dy2 dz2].
%   The result POLY2 is also an array of 3d points, sometimes smaller than
%   poly, and that can be 0-by-3 (empty polygon).
%
%   POLY2 = clipConvexPolygon3dHP(POLY, PT0, NORMAL)
%   uses plane with normal NORMAL and containing point PT0.
%
%
%   See also 
%   polygons3d, polyhedra

% ------
% Author: David Legland
% E-mail: david.legland@inrae.fr
% Created: 2007-01-05
% Copyright 2007-2023 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas

warning('matGeom:deprecated', ...
    'Deprecated function, use ''clipPolygonByPlane3d'' instead');

% ensure last point is the same as the first one
if sum(poly(end