
function [nodes,weights]=define_rule_disk(ade)

% Cubature rule on the unit disk with ADE equal to ade.
% Note: As output, the nodes will be in cartesian coordinates.

% shifted gaussian rule: r direction
m=ceil((ade+1)/2);
abm=r_jacobi(m,0,0); yv=gauss(m,abm); % Gauss-Legendre
rnodes=(yv(:,1)+1)/2; rw=yv(:,2)/2; 

% trapezoidal rule, consider first and last node repetition
N=ade+2;
t=linspace(0,2*pi,N); t=t(1:end-1); t=t';
tw=(2*pi/(N-1))*ones(N-1,1);

% define tensorial rule
[r_mat,th_mat]=meshgrid(rnodes,t);
[r_matw,th_matw]=meshgrid(rw,tw);

x_mat=r_mat.*cos(th_mat); y_mat=r_mat.*sin(th_mat); 
w_mat=r_matw.*th_matw.*r_mat;

nodes=[x_mat(:) y_mat(:)]; weights=w_mat(:);
