Returns the average length of each faces in a mesh.
vertices (torch.Tensor) – Batched vertices, of shape \((\text{batch_size}, \text{num_vertices}, 3)\).
faces (torch.LongTensor) – Faces, of shape \((\text{num_faces}, 3)\).
average length of each edges in a face, of shape \((\text{batch_size}, \text{num_faces})\).
Example
>>> vertices = torch.tensor([[[1, 0, 0],
... [0, 1, 0],
... [0, 0, 1]]], dtype=torch.float)
>>> faces = torch.tensor([[0, 1, 2]])
>>> average_edge_length(vertices, faces)
tensor([[1.4142]])
Computes the distances from pointclouds to meshes (represented by vertices and faces).
For each point in the pointcloud, it finds the nearest triangle in the mesh, and calculated its distance to that triangle.
Note
The calculated distance is the squared, unsigned Euclidean distance.
Distance-type codes:
0 - projection lies inside the triangle (face distance)
1 - nearest to vertex 0
2 - nearest to vertex 1
3 - nearest to vertex 2
4 - nearest to edge 0-1
5 - nearest to edge 1-2
6 - nearest to edge 2-0
pointclouds (torch.Tensor) – pointclouds, of shape \((\text{batch_size}, \text{num_points}, 3)\).
face_vertices (torch.Tensor) – vertices of each face of meshes, of shape \((\text{batch_size}, \text{num_faces}, 3, 3)\).
Squared distances between pointclouds and meshes, of shape \((\text{batch_size}, \text{num_points})\).
Face indices selected, of shape \((\text{batch_size}, \text{num_points})\).
Distance types, of shape \((\text{batch_size}, \text{num_points})\).
(torch.Tensor, torch.LongTensor, torch.IntTensor)
Example
>>> from kaolin.ops.mesh import index_vertices_by_faces
>>> point = torch.tensor([[[0.5, 0.5, 0.5],
... [3., 4., 5.]]], device='cuda')
>>> vertices = torch.tensor([[[0., 0., 0.],
... [0., 1., 0.],
... [0., 0., 1.]]], device='cuda')
>>> faces = torch.tensor([[0, 1, 2]], dtype=torch.long, device='cuda')
>>> face_vertices = index_vertices_by_faces(vertices, faces)
>>> distance, index, dist_type = point_to_mesh_distance(point, face_vertices)
>>> distance
tensor([[ 0.2500, 41.0000]], device='cuda:0')
>>> index
tensor([[0, 0]], device='cuda:0')
>>> dist_type
tensor([[5, 5]], device='cuda:0', dtype=torch.int32)
Calculates the uniform laplacian smoothing of meshes. The position of updated vertices is defined as \(V_i = \frac{1}{N} * \sum^{N}_{j=1}V_j\), where \(N\) is the number of neighbours of \(V_i\), \(V_j\) is the position of the j-th adjacent vertex.
vertices (torch.Tensor) – Vertices of the meshes, of shape \((\text{batch_size}, \text{num_vertices}, 3)\).
faces (torch.LongTensor) – Faces of the meshes, of shape \((\text{num_faces}, \text{face_size})\).
smoothed vertices, of shape \((\text{batch_size}, \text{num_vertices}, 3)\).
(torch.FloatTensor)
Example
>>> vertices = torch.tensor([[[1, 0, 0],
... [0, 1, 0],
... [0, 0, 1]]], dtype=torch.float)
>>> faces = torch.tensor([[0, 1, 2]])
>>> uniform_laplacian_smoothing(vertices, faces)
tensor([[[0.0000, 0.5000, 0.5000],
[0.5000, 0.0000, 0.5000],
[0.5000, 0.5000, 0.0000]]])