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

Increase precision in centroid calculation to fix #61 #62

Closed
wants to merge 3 commits into from
Closed

Increase precision in centroid calculation to fix #61 #62

wants to merge 3 commits into from

Conversation

Yaraslaut
Copy link

Here is the link for the issue #61
As one can see from description error in initilization appears to be originated from some numerical instability during basic operations.
Added:

  • unit test covering the bug
  • fix of the bug.

centroid = vector3_plus(centroid, vertices[nv]);
prsm->centroid = centroid = vector3_scale(1.0 / ((double)num_vertices), centroid);
centroid = vector3_plus(centroid, vector3_scale(1.0 / (double)num_vertices, vertices[nv]));
prsm->centroid = centroid;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't increase the precision, it just re-orders the scale factor; there's no guarantee that it will be more accurate.

Probably some coplanar check just needs a floating-point tolerance.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't increase the precision, it just re-orders the scale factor; there's no guarantee that it will be more accurate.

Probably some coplanar check just needs a floating-point tolerance.

Naturally you are right, i left comment here #61 (comment) with detailed description why this error arrise.

@Yaraslaut Yaraslaut closed this Oct 3, 2022
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

Successfully merging this pull request may close these issues.

2 participants