%% Convert Barycentric Coordinates to Cartesian Coordinates
% Create a triangulation from a set of points P and a triangulation connectivity list T, and plot the triangulation.

P = [2.5 8.0; 6.5 8.0; 2.5 5.0; 6.5 5.0; 1.0 6.5; 8.0 6.5];
T = [5 3 1; 3 2 1; 3 4 2; 4 6 2];
TR = triangulation(T,P);
triplot(TR)

% Specify the identification number of the first (leftmost) triangle in TR, and the barycentric coordinates of the triangle's second point.

ID = 1;
B = [0 1 0];

% Convert the barycentric coordinates to Cartesian coordinates with respect to the first triangle in TR.

C = barycentricToCartesian(TR,ID,B)

% Copyright 2015 The MathWorks, Inc.