

function XYZW=map_baricentric_rules(XYZW_bar,vertices)

% The variable "XYZW_bar is a matrix with "m" rows (that is the
% cardinality of the cubature pointset) and 5 columns.
% The first four columns are the baricentric coordinates of the nodes of a
% rule over a reference tetrahedron, while the fifth column represent the 
% corresponding weights.
% Sum of the weights in XYZW_bar must be equal to 1.

% Mapping nodes
XYZ_bar=XYZW_bar(:,1:4);

XYZ=XYZ_bar*vertices;

% Determining pertinent weights.
volume=volume_tetrahedron(vertices);
W=volume*XYZW_bar(:,5);

% Assembling rule.
XYZW=[XYZ W];
