function l_p_dist = point_line_distance_signed ( p1, p2, p )

%*****************************************************************************80
%
%% point_line_distance_signed() computes the signed distance between a point and a line.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 July 2023
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real p1(2), p2(2): two distinct points, defining a line.
%
%    real p(2): a point.
%
%  Output:
%
%    l_p_dist: the signed distance between p and the line through p1 and p2.
%
  l_dv = p2 - p1;

  fprintf ( 1, '  Direction vector L.DV = (%f  %f)\n', l_dv );

  l_nv(1,1) = - l_dv(2);
  l_nv(2,1) =   l_dv(1);

  l_nv = l_nv / sqrt ( l_nv(1)^2 + l_nv(2)^2 );

  fprintf ( 1, '  Normal vector L.NV = [%f  %f]\n', l_nv );

  l_p_dist = l_nv' * ( p - p1 );

  return
end

