medusa.geometry
#
Module with geometry-related functionality.
For now only contains functions to compute vertex and triangle normals.
Module Contents#
- medusa.geometry.compute_tri_normals(v, tris, normalize=True)[source]#
Computes triangle (surface/face) normals.
- Parameters:
v (torch.tensor) – A float tensor with vertices of shape B (batch size) x V (vertices) x 3
tris (torch.tensor) – A long tensor with indices of shape T (triangles) x 3 (vertices per triangle)
normalize (bool) – Whether to normalize the normals (usually, you want to do this, but included here so it can be reused when computing vertex normals, which uses unnormalized triangle normals)
- Returns:
fn – A float tensor with triangle normals of shape B (batch size) x T (triangles) x 3
- Return type:
torch.tensor
- medusa.geometry.compute_vertex_normals(v, tris)[source]#
Computes vertex normals in a vectorized way, based on the
pytorch3d
implementation.- Parameters:
v (torch.tensor) – A float tensor with vertices of shape B (batch size) x V (vertices) x 3
tris (torch.tensor) – A long tensor with indices of shape T (triangles) x 3 (vertices per triangle)
- Returns:
vn – A float tensor with vertex normals of shape B (batch size) x V (vertices) x 3
- Return type:
torch.tensor
- medusa.geometry.apply_vertex_mask(name, **attrs)[source]#
Applies a vertex mask to a tensor of vertices.
- Parameters:
v (torch.tensor) – A float tensor with vertices of shape B (batch size) x V (vertices) x 3
name (str) – Name of mask to apply
- Returns:
v_masked – A float tensor with masked vertices of shape B (batch size) x V (vertices) x 3
- Return type:
torch.tensor