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

Correctly calculate incenter in Triangle::inscribed_circle #387

Merged
merged 2 commits into from
Oct 31, 2024

Conversation

tomcur
Copy link
Member

@tomcur tomcur commented Oct 7, 2024

The method erroneously calculated the circumcenter instead.

Tagging along on this PR are some changes to the triangle tests that I used to track down some issues. If desired I can bump these to a separate PR. The asserts testing approximate equality now take a relative epsilon, making them a bit more useful for testing values differing in orders of magnitude. I've also recalculated some of the test values to specify them at 17 significant digits (absolute limit of f64), and made the equality bounds tighter.

The method erroneously calculated the circumcenter instead.

This also changes the triangle tests to allow specifying a relative
epsilon in the approximately-equal asserts, making them a bit more
useful for testing values differing in orders of magnitude.
tomcur added a commit to tomcur/kurbo that referenced this pull request Oct 8, 2024
(On top of PR linebender#387, as I'm removing a method here that is still used
until that PR is merged. I'll keep this in draft until then.)

This is based on the simplified form for Cartesian coordinates in
https://en.wikipedia.org/w/index.php?title=Circumcircle&oldid=1247179617#Cartesian_coordinates_2

Also adds a test to check the circle radius' sign is equal to the sign
of the triangle's area.
Copy link
Contributor

@raphlinus raphlinus left a comment

Choose a reason for hiding this comment

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

Looks good, and thanks. I didn't carefully check the math for calculation of the incenter, but looks like you have.

src/triangle.rs Show resolved Hide resolved
@tomcur tomcur enabled auto-merge October 31, 2024 10:22
@tomcur tomcur added this pull request to the merge queue Oct 31, 2024
Merged via the queue into linebender:main with commit da9bc17 Oct 31, 2024
15 checks passed
@tomcur tomcur deleted the incenter branch October 31, 2024 10:25
tomcur added a commit to tomcur/kurbo that referenced this pull request Oct 31, 2024
(On top of PR linebender#387, as I'm removing a method here that is still used
until that PR is merged. I'll keep this in draft until then.)

This is based on the simplified form for Cartesian coordinates in
https://en.wikipedia.org/w/index.php?title=Circumcircle&oldid=1247179617#Cartesian_coordinates_2

Also adds a test to check the circle radius' sign is equal to the sign
of the triangle's area.
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