Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TriMesh::cornerangle uses incorrect formula for angle from known dot-product. #20

Open
terraformist opened this issue Sep 21, 2022 · 1 comment

Comments

@terraformist
Copy link

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);
}

@Forceflow
Copy link
Owner

create a PR for this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants