Fix cylinder point containment - #28
Merged
VonTum merged 1 commit intoSep 21, 2026
Merged
Conversation
Square the Y coordinate in the radial check to correctly classify points inside and outside the cylinder.
Member
|
Oh, you are correct. Well spotted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #29
cylinderShape(1, 2).containsPoint(...)rejects(0, 0.75, 0), which is inside the cylinder, and accepts(0, -2, 0), which is outside. The radial check usesx*x + y + y, breaking the cylinder's symmetry.Replace
y + ywithy * yso the check evaluatesx*x + y*y. The two queries now returntrueandfalse, respectively.Validation: built the standalone physics library in Debug mode with GCC 16.0.1 and ran all 13 geometry tests successfully. A local regression test failed before the fix and passed afterward with 30 assertions covering both signs of X/Y, two radii, and radial and cap boundaries. That test and the standalone reproducer are not included in this PR; this PR contains only the one-line implementation fix. The full project test suite was not run.
Local regression test
This is the test run from
tests/geometryTests.cppbefore applying the fix. It failed on the original implementation becausecontainsPoint(Vec3(0.0, -2.0, 0.0))returnedtruefor a radius-1 cylinder, although the point is outside. After the fix, the same test passed all 30 assertions, and all 13 geometry tests passed. The failure demonstrated the existing bug; it was not a failure introduced by this PR.The test is reproduced below for reference. It remains local and is not included in the committed changes.