Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

barycentricToCartesian

Class: triangulation

Converts point coordinates from barycentric to Cartesian

Syntax

PC = barycentricToCartesian(TR,ti,B)

Description

PC = barycentricToCartesian(TR,ti,B) returns the Cartesian coordinates of the points in B. Each row, B(j,:), contains the barycentric coordinates of a point with respect to the triangle or tetrahedron, ti(j). The point, PC(j,:), is the jth point represented in Cartesian coordinates.

Input Arguments

TR

Triangulation representation, see triangulation or delaunayTriangulation.

ti

Triangle or tetrahedron IDs, specified as a column vector.

B

Barycentric coordinates, specified as a matrix. Each row, B(j,:), contains the barycentric coordinates of a point with respect to the triangle or tetrahedron, ti(j).

Output Arguments

PC

Cartesian coordinates, returned as a matrix. The point, PC(j,:), is the jth point represented in Cartesian coordinates.

Definitions

Triangle or Tetrahedron ID

A row number of the matrix, TR.ConnectivityList. Use this ID to refer a specific triangle or tetrahedron.

Examples

expand all

Create a triangulation from a set of points, P, and triangulation connectivity list, T.

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);

Specify the first triangle.

ti = 1;

Specify the barycentric coordinates of the second point in the triangle.

B = [0 1 0];

Convert the point to Cartesian coordinates.

PC = barycentricToCartesian(TR,ti,B)
PC =

    2.5000    5.0000

Create a Delaunay triangulation from a set of points.

x = [0 4 8 12 0 4 8 12]';
y = [0 0 0 0 8 8 8 8]';
DT = delaunayTriangulation(x,y);

Calculate the Cartesian coordinates of the incenters.

cc = incenter(DT);

Plot the original triangulation and reference points.

figure
subplot(1,2,1);
triplot(DT);
hold on;
plot(cc(:,1),cc(:,2),'*r');
hold off;
axis equal;

Create a new triangulation which is a deformed version of DT .

ti = DT.ConnectivityList;
y = [0 0 0 0 16 16 16 16]';
TR = triangulation(ti,x,y);

Compute the barycentric coordinates for the incenters of DT, and use them to compute the Cartesian coordinates of the analogous points in TR.

b = cartesianToBarycentric(DT,[1:length(ti)]',cc);
xc = barycentricToCartesian(TR,[1:length(ti)]',b);

Plot the deformed triangulation and mapped locations of the reference points.

subplot(1,2,2);
triplot(TR);
hold on;
plot(xc(:,1),xc(:,2),'*r');
hold off;
axis equal;

Was this topic helpful?