according to a formula for dot product:
a_vec dot b_vec = a_mod b_mod cos(angle_a_b)
TriMesh::cornerangle misses a_mod * b_mod and the code should be:
inline float cornerangle(int i, int j)
{
using namespace ::std;
if (unlikely(faces.empty())) need_faces();
const point &p0 = vertices[faces[i][j]];
const point &p1 = vertices[faces[i][NEXT_MOD3(j)]];
const point &p2 = vertices[faces[i][PREV_MOD3(j)]];
// new lines down from here
const point &v1 = p1 - p0;
const point &v2 = p2 - p0;
const float m = len(v1) * len(v2);
// return line is replaced
return acos(v1.dot(v2) / m);
}
according to a formula for dot product: a_vec dot b_vec = a_mod b_mod cos(angle_a_b)
TriMesh::cornerangle misses a_mod * b_mod and the code should be:
inline float cornerangle(int i, int j) { using namespace ::std;
// new lines down from here const point &v1 = p1 - p0; const point &v2 = p2 - p0; const float m = len(v1) * len(v2); // return line is replaced return acos(v1.dot(v2) / m); }