function stla_io_test05

%*****************************************************************************80
%
%% TEST05 tests STLA_FACE_NORMAL_COMPUTE.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    24 September 2005
%
%  Author:
%
%    John Burkardt
%
  face_num = 12;
  node_num = 8;

  face_node = [ ...
    1, 3, 2; ...
    2, 3, 4; ...
    1, 6, 5; ...
    1, 2, 6; ...
    3, 7, 4; ...
    4, 7, 8; ...
    5, 6, 8; ...
    5, 8, 7; ...
    1, 5, 7; ...
    1, 7, 3; ...
    2, 4, 6; ...
    6, 4, 8 ]';
  face_normal = [ ...
    0.0,  0.0, -1.0; ...
    0.0,  0.0, -1.0; ...
    0.0, -1.0,  0.0; ...
    0.0, -1.0,  0.0; ...
    0.0, +1.0,  0.0; ...
    0.0, +1.0,  0.0; ...
    0.0,  0.0, +1.0; ...
    0.0,  0.0, +1.0; ...
   -1.0,  0.0,  0.0; ...
   -1.0,  0.0,  0.0; ...
   +1.0,  0.0,  0.0; ...
   +1.0,  0.0,  0.0 ]';
  node_xyz = [ ...
    0.0, 0.0, 0.0; ...
    1.0, 0.0, 0.0; ...
    0.0, 1.0, 0.0; ...
    1.0, 1.0, 0.0; ...
    0.0, 0.0, 1.0; ...
    1.0, 0.0, 1.0; ...
    0.0, 1.0, 1.0; ...
    1.0, 1.0, 1.0 ]';

  fprintf ( 1, '\n' );
  fprintf ( 1, 'TEST05\n' );
  fprintf ( 1, '  STLA_FACE_NORMAL_COMPUTE computes the face normal\n' );
  fprintf ( 1, '  vectors for an STLA file.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  We have an STLA solid, and its exact normals.\n' );
  fprintf ( 1, '  We now call STLA_FACE_NORMAL_COMPUTE to\n' );
  fprintf ( 1, '  recompute the normals.\n' );

  face_normal2 = stla_face_normal_compute ( node_num, face_num, node_xyz, ...
    face_node );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  We print out the maximum error, defined as\n' );
  fprintf ( 1, '    |1 - dot ( n1, n2 )|\n' );
  fprintf ( 1, '  where n1 and n2 are the exact and computed normals.\n' );

  dot_max = 0.0;

  for face = 1 : face_num

    dot_max = max ( dot_max, abs ( 1.0 - ...
      face_normal(1:3,face)' * face_normal2(1:3,face) ) );

  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Maximum error = %f\n', dot_max );

  return
end
