d0 = d0 / torch.norm(d0) d1 = v[(i + 2) % 3] - v[i] d1 = d1 / torch.norm(d1) d = torch.sum(d0*d1, 0) Here, the norm is not calculated per-vertex