tfg.math.interpolation.weighted.get_barycentric_coordinates
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.
|
Args |
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".
|
Returns |
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 is Truewhere
pixels are inside the triangle, and False` otherwise.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-10-28 UTC.
[null,null,["Last updated 2022-10-28 UTC."],[],[]]