tfg.math.interpolation.weighted.get_barycentric_coordinates

Computes the barycentric coordinates of pixels for 2D triangles.

Barycentric coordinates of a point p are represented as coefficients \((w_1, w_2, w_3)\) corresponding to the masses placed at the vertices of a reference triangle if p is the center of mass. Barycentric coordinates are normalized so that \(w_1 + w_2 + w_3 = 1\). These coordinates play an essential role in computing the pixel attributes (e.g. depth, color, normals, and texture coordinates) of a point lying on the surface of a triangle. The point p is inside the triangle if all of its barycentric coordinates are positive.

In the following, A1 to An are optional batch dimensions.

triangle_vertices A tensor of shape [A1, ..., An, 3, 2], where the last two dimensions represents the x and y coordinates for each vertex of a 2D triangle.
pixels A tensor of shape [A1, ..., An, N, 2], where N represents the number of pixels, and the last dimension represents the x and y coordinates of each pixel.
name A name for this op that defaults to "rasterizer_get_barycentric_coordinates".

barycentric_coordinates A float tensor of shape [A1, ..., An, N, 3], representing the barycentric coordinates.
valid A boolean tensor of shape [A1, ..., An, N], which isTruewhere pixels are inside the triangle, andFalse` otherwise.