View source on GitHub |
Computes the barycentric coordinates of pixels for 2D triangles.
tfg.math.interpolation.weighted.get_barycentric_coordinates(
triangle_vertices: type_alias.TensorLike,
pixels: type_alias.TensorLike,
name: str = 'rasterizer_get_barycentric_coordinates'
) -> type_alias.TensorLike
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.
Note | |
---|---|
In the following, A1 to An are optional batch dimensions. |