MCPcopy Create free account
hub / github.com/Colin97/DeepMetaHandles / triangle_area

Function triangle_area

src/losses.py:8–13  ·  view source on GitHub ↗
(v, f)

Source from the content-addressed store, hash-verified

6import pytorch3d
7
8def 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
15def normal_loss(src_meshes, def_meshes):
16 N = len(src_meshes)

Callers 1

normal_lossFunction · 0.85

Calls 1

crossMethod · 0.80

Tested by

no test coverage detected