Geometry utils#

face_info

Given a set of vertices v and indices vi indexing into v defining a set of faces, compute face information (normals, edges, face areas) for each face.

vert_binormals

vert_normals

Given a set of vertices v and indices vi indexing into v defining a set of faces, compute normals for each vertex by averaging the face normals for each face which includes that vertex.

drtk.utils.geometry.face_info(v, vi, to_compute=None)[source]#

Given a set of vertices v and indices vi indexing into v defining a set of faces, compute face information (normals, edges, face areas) for each face.

Parameters:
  • v – Vertex positions, shape [batch_size, n_vertices, 3]

  • vi – Vertex indices, shape [n_faces, 3]

  • to_compute – list of desired information. Any of: {normals, edges, areas}, defaults to all.

Returns:

Face information in the following format:

{
    "normals": shape [batch_size, n_faces, 3]
    "edges":   shape [batch_size, n_faces, 3, 3]
    "areas":   shape [batch_size, n_faces, 1]
}

or just one of the above values not in a Dict if only one is requested.

Return type:

Dict

drtk.utils.geometry.vert_binormals(v, vt, vi, vti)[source]#
drtk.utils.geometry.vert_normals(v, vi, fnorms=None)[source]#

Given a set of vertices v and indices vi indexing into v defining a set of faces, compute normals for each vertex by averaging the face normals for each face which includes that vertex.

Parameters:
  • v – Vertex positions, shape [batch_size, n_vertices, 3]

  • vi – Vertex indices, shape [batch_size, n_faces, 3]

  • fnorms – Face normals. Optional, provide them if available, otherwise they will be computed from v and vi. Shape [n_faces, 3]

Returns:

Vertex normals, shape [batch_size, n_vertices, 3]

Return type:

th.Tensor