function arc_length = polyline_length_nd ( dim_num, nk, pk )

%*****************************************************************************80
%
%% polyline_length_nd() computes the length of a polyline in ND.
%
%  Discussion:
%
%    A polyline of order NK is the geometric structure consisting of
%    the NK-1 line segments that lie between successive elements of a list
%    of NK points.
%
%    An ordinary line segment is a polyline of order 2.
%    The letter "V" is a polyline of order 3.
%    The letter "N" is a polyline of order 4, and so on.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 March 2005
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer DIM_NUM, the spatial dimension.
%
%    integer NK, the number of points defining the polyline.
%
%    real PK(DIM_NUM,NK), the points defining the polyline.
%
%  Output:
%
%    real ARC_LENGTH, the length of the polyline.
%
  arc_length = 0.0;

  for i = 2 : nk

    arc_length = arc_length ...
      + sqrt ( sum ( ( pk(1:dim_num,i) - pk(1:dim_num,i-1) ).^2 ) );

  end

  return
end
