(v, f)
| 6 | import pytorch3d |
| 7 | |
| 8 | def triangle_area(v, f): |
| 9 | A = torch.gather(v, 0, f[:, 0].unsqueeze(-1).expand(-1, 3)) |
| 10 | B = torch.gather(v, 0, f[:, 1].unsqueeze(-1).expand(-1, 3)) |
| 11 | C = torch.gather(v, 0, f[:, 2].unsqueeze(-1).expand(-1, 3)) |
| 12 | normal = torch.cross((B - A), (C - A), dim = -1) |
| 13 | return normal.norm(p = 2, dim = -1) |
| 14 | |
| 15 | def normal_loss(src_meshes, def_meshes): |
| 16 | N = len(src_meshes) |