barycentricToCartesian

Converts barycentric coordinates in given triangles or tetrahedra to Cartesian coordinates.

Category: Mathematics > Computational Geometry

Syntax

C = barycentricToCartesian(TR, T, B)

Maps the barycentric rows of B, each relative to the simplex listed in T, to points in space.

Description

A point with barycentric coordinates (b1, b2, b3) in a triangle is the weighted sum b1*P1 + b2*P2 + b3*P3 of the triangle's vertices. This function does that weighted sum for each requested simplex, using the vertices stored in the triangulation.

Weights inside [0, 1] give points inside the simplex; negative weights give points outside it. It is the inverse of cartesianToBarycentric.

Input arguments

TR
A triangulation or delaunayTriangulation object (2-D, or 3-D tetrahedral).
T
Column vector of simplex (row) indices of TR.ConnectivityList.
B
Barycentric coordinates, one row per entry in T, with 3 columns for triangles and 4 for tetrahedra. Each row should sum to 1.

Output arguments

C
Cartesian coordinates, one row per row of B.

Example

Point inside the first triangle

x = [0 1 1 0 0.5]';
y = [0 0 1 1 0.5]';
DT = delaunayTriangulation(x, y);
C = barycentricToCartesian(DT, 1, [0.2 0.3 0.5])
Output
C = 1×2

    0.9000    0.6000

See also

cartesianToBarycentric pointLocation delaunayTriangulation triangulation