function err = triangle_right_error ( v )

%*****************************************************************************80
%
%% triangle_right_error() reports how close a triangle is to being right.
%
%  Discussion:
%
%    err = a^2 + b^2 - c^2.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 February 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real V(3,2), the vertices of the triangle.
%
%  Output:
%
%    real ERR, the value of a^2+b^2-c^2.
%

%
%  Get the side lengths.
%
  t = zeros ( 3, 1 );
  t(1) = norm ( v(1,:) - v(2,:) );
  t(2) = norm ( v(2,:) - v(3,:) );
  t(3) = norm ( v(3,:) - v(1,:) );
%
%  Sort the side lengths.
%
  [ t, index ] = sort ( t );

  v = v(index,:);
%
%  Set c to the longest side.
%
  a = t(1);
  b = t(2);
  c = t(3);
%
%  Make the test.
%
  err = a^2 + b^2 - c^2;

  return
end
