function segment_length = p14_boundary_segment_length ( segment_index, h )

%*****************************************************************************80
%
%% P14_BOUNDARY_SEGMENT_LENGTH returns boundary segment lengths in problem 14.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    12 April 2009
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer SEGMENT_INDEX, the index of one of the boundary segments.
%
%    Input, real H, the suggested spacing between points.
%
%    Output, integer SEGMENT_LENGTH, the number of points in the segment.
%
  n1 = 90;
  n2 = 11;
  
  v1 = [ ...
    316.43027, 404.47559; ...
    291.04946, 400.70917; ...
    265.16504, 409.77890; ...
    241.46794, 402.40310; ...
    216.55145, 396.52064; ...
    163.28492, 411.37102; ...
    142.81752, 391.16355; ...
    111.95404, 346.70264; ...
    100.03538, 325.72710; ...
    103.98723, 302.51587; ...
    128.72978, 285.72802; ...
    147.49111, 266.23345; ...
    196.65261, 242.24055; ...
    213.56835, 221.67192; ...
    226.49969, 198.09326; ...
    248.37126, 183.50473; ...
    262.21952, 165.39102; ...
    278.42330, 149.91715; ...
    300.71846, 145.82601; ...
    311.12698, 166.71094; ...
    326.66315, 184.58335; ...
    359.78574, 225.48049; ...
    357.08892, 252.88958; ...
    358.76685, 285.34403; ...
    361.50834, 303.71287; ...
    371.68926, 314.92452; ...
    380.49890, 324.58632; ...
    396.37634, 328.88990; ...
    412.59116, 327.25238; ...
    425.48394, 315.28623; ...
    435.84305, 302.44664; ...
    458.34025, 297.55121; ...
    479.66439, 288.99238; ...
    493.09812, 270.20636; ...
    518.87309, 264.56427; ...
    547.18014, 268.18846; ...
    600.49708, 240.62570; ...
    625.96183, 238.40347; ...
    633.90530, 260.70629; ...
    621.50451, 285.88914; ...
    576.87224, 322.14121; ...
    570.51915, 348.85423; ...
    567.16400, 378.24075; ...
    558.00668, 406.86552; ...
    565.19008, 435.75599; ...
    567.56437, 465.33407; ...
    550.87626, 490.96358; ...
    532.98174, 515.84491; ...
    500.66817, 551.89078; ...
    478.75120, 562.17222; ...
    430.03371, 583.94286; ...
    401.20454, 587.69910; ...
    368.32214, 581.10110; ...
    354.26303, 585.86085; ...
    346.75200, 601.10367; ...
    332.85137, 628.74602; ...
    308.02188, 645.84180; ...
    295.52344, 647.18525; ...
    286.51519, 651.60328; ...
    285.98846, 662.07339; ...
    298.93455, 665.66316; ...
    301.70226, 682.79570; ...
    278.65857, 689.63850; ...
    266.25737, 712.11005; ...
    287.28701, 732.77147; ...
    318.19548, 736.85151; ...
    343.83067, 753.60957; ...
    375.53164, 758.35231; ...
    405.73444, 768.98687; ...
    406.33873, 785.59001; ...
    378.35436, 789.44240; ...
    350.02151, 795.02238; ...
    338.68030, 788.87325; ...
    325.67930, 786.10177; ...
    319.05995, 798.04657; ...
    301.78158, 795.34254; ...
    280.69272, 773.86634; ...
    254.55844, 758.02898; ...
    234.07759, 737.42090; ...
    218.38337, 711.41500; ...
    220.99086, 682.17833; ...
    224.50640, 651.96297; ...
    240.25971, 631.36117; ...
    259.86174, 612.60253; ...
    291.85381, 556.70385; ...
    315.52139, 537.56387; ...
    341.63663, 520.12519; ...
    351.37130, 458.75372; ...
    349.33183, 431.31454; ...
    328.80465, 412.43055 ]';
  v2 = [ ...
    238.64853, 266.58978; ...
    235.14026, 287.95183; ...
    238.20736, 303.46785; ...
    250.13902, 303.71290; ...
    258.51675, 297.46973; ...
    274.55300, 291.27357; ...
    284.66230, 280.72063; ...
    279.73288, 267.83455; ...
    270.68478, 255.55440; ...
    255.73801, 249.16872; ...
    241.72690, 256.73448 ]';

  if ( h <= 0.0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'P14_BOUNDARY_SEGMENT_LENGTH - Fatal error!' );
    fprintf ( 1, '  Nonpositive H = %f\n', h );
    error ( 'P14_BOUNDARY_SEGMENT_LENGTH - Fatal error!' );
  end

  if ( segment_index == 1 )

    length = polyloop_length_nd ( 2, n1, v1 ) ;

  elseif ( segment_index == 2 )

    length = polyloop_length_nd ( 2, n2, v2 );

  else

    fprintf ( 1, '\n' );
    fprintf ( 1, 'P14_BOUNDARY_SEGMENT_LENGTH - Fatal error!' );
    fprintf ( 1, '  Illegal SEGMENT_INDEX = %d\n', segment_index );
    error ( 'P14_BOUNDARY_SEGMENT_LENGTH - Fatal error!' );

  end

  n = round ( length / h );

  segment_length = n;

  return
end
