function [ n, w, x, y, z ] = triangle_symq_to_ref ( degree )

%*****************************************************************************80
%
%% triangle_symq_to_ref() converts a quadrature rule from symmetric to ref form.
%
%  Discussion:
%
%    The quadrature rule is originally defined over an equilateral triangle.
%
%    This function requests a conversion of the rule so that it applies
%    to the reference triangle on the half-unit square, bounded by
%    (0,0), (1,0), (0,1).
%
%  Licensing:
%
%    This code is distributed under the GNU GPL license.
%
%  Modified:
%
%    28 March 2023
%
%  Author:
%
%    Original FORTRAN77 version by Hong Xiao, Zydrunas Gimbutas.
%    This version by John Burkardt.
%
%  Reference:
%
%    Hong Xiao, Zydrunas Gimbutas,
%    A numerical algorithm for the construction of efficient quadrature
%    rules in two and higher dimensions,
%    Computers and Mathematics with Applications,
%    Volume 59, 2010, pages 663-676.
%
%  Input:
%
%    integer DEGREE, the desired total degree exactness.
%    0 <= DEGREE <= 50.
%
%  Output:
%
%    integer N: the number of nodes.
%
%    real W(N): the quadrature weights.
%
%    real X(N), Y(N), Z(N): the coordinates of the nodes.

  addpath ( '../triangle_symq_rule' );

  vert1 = [ 0.0, 0.0 ];
  vert2 = [ 1.0, 0.0 ];
  vert3 = [ 0.0, 1.0 ];

  n = rule_order ( degree );
%
%  Retrieve a symmetric quadrature rule.
%
  [ rnodes, w ] = triasymq ( degree, vert1, vert2, vert3, n );

  x = rnodes(1,:);
  y = rnodes(2,:);
  z = 1.0 - x - y;

  rmpath ( '../triangle_symq_rule' );

  return
end

