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: createLine3d.m
    path of file: ./repos/matGeom/matGeom/geom3d
    
    the code of the file until where you have to start completion: function line = createLine3d(varargin)
%CREATELINE3D Create a line with various inputs.
%
%   Line is represented in a parametric form : [x0 y0 z0 dx dy dz]
%       x = x0 + t*dx
%       y = y0 + t*dy;
%       z = z0 + t*dz;
%
%
%   L = createLine3d(P1, P2);
%   Returns the line going through the two given points P1 and P2.
%   
%   L = createLine3d(X0, Y0, Z0, DX, DY, DZ);
%   Returns the line going through the point [x0, y0, z0], and with
%   direction vector given by [DX DY DZ]. 
%
%   L = createLine3d(P0, DX, DY, DZ);
%   Returns the line going through point P0 given by [x0, y0, z0] and with
%   direction vector given by [DX DY DZ]. 
%
%   L = createLine3d(THETA, PHI);
%   Create a line originated at (0,0) and with angles theta and phi.
%
%   L = createLine3d(P0, THETA, PHI);
%   Create a line with direction given by theta and phi, and which contains
%   point P0. 
%
%
%   Note : in all cases, parameters can be vertical arrays of the same
%   dimension. The result is then an array of lines, of dimensions [N*6].
%
%   See also 
%   lines3d

% ------
% Author: David Legland 
% E-mail: david.legland@inrae.fr
% Created: 2005-02-17
% Copyright 2005-2023 INRA - TPV URPOI - BIA IMASTE

%   NOTE : A 3d line can also be represented with a 1*7 array : 
%   [x0 y0 z0 dx dy dz t].
%   whith 't' being one of the following : 
%   - t=0 : line is a singleton (x0,y0)
%   - t=1 : line is an edge segment, between points (x0,y0) and (x0+dx,
%   y0+dy).
%   - t=Inf : line is a Ray, originated from (x0,y0) and going to infinity
%   in the direction(dx,dy).
%   - t=-Inf : line is a Ray, originated from (x0,y0) and going to infinity
%   in the direction(-dx,-dy).
%   - t=NaN : line is a real straight line, and contains all points
%   verifying the above equation.
%   This seems to be a convenient way to represent uniformly all kind of
%   lines (including edges, rays, and even point).
%
%   NOTE2 : Another form is the 1*8 array :
%   [x0 y0 z0 dx dy dz t1 t2].
%   with t1 and t2 giving first and last position of the edge on the
%   supporting straight line, and with t2>t1.

if length(varargin)==1    
    error('Wrong number of arguments in ''createLine'' ');
    
elseif length(varargin)==2    
    % 2 input parameters. They can be :
    % - 2 points, then 2 arrays of 1*2 double.
    v1 = varargin{1};
    v2 = varargin{2};
    if size(v1, 2)==3
        % first input parameter is first point, and second input is the
        % second point.
        line = [v1(:,1) v1(:,2) v1(:,3) v2(:,1)-v1(:,1) v2(:,2)-v1(:,2) v2(:,3)-v1(:,3)];    
    elseif size(v1, 2)==1
        % first parameter is angle with the vertical
        % second parameter is horizontal angle with Ox axis
        theta = varargin{1};
        phi = varargin{2};

        sit = sin(theta);

    
function line = createLine3d(varargin)
%CREATELINE3D Create a line with various inputs.
%
%   Line is represented in a parametric form : [x0 y0 z0 dx dy dz]
%       x = x0 + t*dx
%       y = y0 + t*dy;
%       z = z0 + t*dz;
%
%
%   L = createLine3d(P1, P2);
%   Returns the line going through the two given points P1 and P2.
%   
%   L = createLine3d(X0, Y0, Z0, DX, DY, DZ);
%   Returns the line going through the point [x0, y0, z0], and with
%   direction vector given by [DX DY DZ]. 
%
%   L = createLine3d(P0, DX, DY, DZ);
%   Returns the line going through point P0 given by [x0, y0, z0] and with
%   direction vector given by [DX DY DZ]. 
%
%   L = createLine3d(THETA, PHI);
%   Create a line originated at (0,0) and with angles theta and phi.
%
%   L = createLine3d(P0, THETA, PHI);
%   Create a line with direction given by theta and phi, and which contains
%   point P0. 
%
%
%   Note : in all cases, parameters can be vertical arrays of the same
%   dimension. The result is then an array of lines, of dimensions [N*6].
%
%   See also 
%   lines3d

% ------
% Author: David Legland 
% E-mail: david.legland@inrae.fr
% Created: 2005-02-17
% Copyright 2005-2023 INRA - TPV URPOI - BIA IMASTE

%   NOTE : A 3d line can also be represented with a 1*7 array : 
%   [x0 y0 z0 dx dy dz t].
%   whith 't' being one of the following : 
%   - t=0 : line is a singleton (x0,y0)
%   - t=1 : line is an edge segment, between points (x0,y0) and (x0+dx,
%   y0+dy).
%   - t=Inf : line is a Ray, originated from (x0,y0) and going to infinity
%   in the direction(dx,dy).
%   - t=-Inf : line is a Ray, originated from (x0,y0) and going to infinity
%   in the direction(-dx,-dy).
%   - t=NaN : line is a real straight line, and contains all points
%   verifying the above equation.
%   This seems to be a convenient way to represent uniformly all kind of
%   lines (including edges, rays, and even point).
%
%   NOTE2 : Another form is the 1*8 array :
%   [x0 y0 z0 dx dy dz t1 t2].
%   with t1 and t2 giving first and last position of the edge on the
%   supporting straight line, and with t2>t1.

if length(varargin)==1    
    error('Wrong number of arguments in ''createLine'' ');
    
elseif length(varargin)==2    
    % 2 input parameters. They can be :
    % - 2 points, then 2 arrays of 1*2 double.
    v1 = varargin{1};
    v2 = varargin{2};
    if size(v1, 2)==3
        % first input parameter is first point, and second input is the
        % second point.
        line = [v1(:,1) v1(:,2) v1(:,3) v2(:,1)-v1(:,1) v2(:,2)-v1(:,2) v2(:,3)-v1(:,3)];    
    elseif size(v1, 2)==1
        % first parameter is angle with the vertical
        % second parameter is horizontal angle with Ox axis
        theta = varargin{1};
        phi = varargin{2};

        sit = sin(theta);
        p0 = zeros([size(theta, 1) 3]);
        
        line = [p0 cos(phi)*sit sin(phi)*sit cos(theta)];
    end