-
Notifications
You must be signed in to change notification settings - Fork 79
Add unit tests and fix bugs for geometry #196
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
Merged
Merged
Conversation
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
7 tasks
omckeon
approved these changes
Feb 25, 2025
Contributor
omckeon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matt439 I've updated some of the unit tests that were failing (such as the line_intersects_rect call that was aiming to be true when the line didn't actually intersect with the rectangle border, which is what the function is checking). :)
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.
Note regarding failed build checks
Running
skunit_testswill produce two failed test cases. The errors occur due topoint_point_distancereturning a float, reducing its precision. This bug is fixed in the following pull request: #195.Description
There are currently only a handful of unit tests covering geometry methods. A comprehensive set of tests have been added which cover all geometry methods in
circle_geometry,geometry,line_geometry,point_geometry,quad_geometry,rectangle_geometry, andtriangle_geometry; with the exception of those which rely on a window. In the process of creating the tests, I discovered multiple bugs and ambiguous documentation which have been also been rectified.Point Method Type Changes
point_in_triangleusesfloatfor its intermediary calculations. This leads to a loss of precision asdot_productoperates atdoubleprecision. Allfloatshave been changed todouble.Circle Methods Ambiguous Description
If
closest_point_on_circleis called whenfrom_ptis equal toc's center position, thenc's center is returned. This is not made clear in the documentation which only mentionsc's circumference. This edge case has been added to the description.closest_point_on_rect_from_circlestrictly returns points on the rectangle's perimeter, even if the rectangle encases the circle. This is not made clear in the description so it has been updated to reduce ambiguity.Tangent Points Bug Fix.
A bug in
tangent_pointswas producing tangent points on the far side of the circle relative to thefrom_pt. This bug has been rectified and now works as intended. I added a real-time graphical test insktest's geometry suite to more easily appreciate how the function operates.Rectangle Type Changes
rectangle_top,rectangle_bottom,rectangle_left, andrectangle_rightreturnfloatwhen the underlying type isdouble. This results in a loss of precision. The functions now returndouble.Triangle-Rectangle Intersect Test
I added a real-time graphical test to
sktest's geometry suite to check the operation oftriangle_rectangle_intersect. The function works as intended without any need for changes.Set Quad Point Bug Fix
set_quad_pointincorrectly checks whetheridxis between the bounds of 0 and 3 and does not allow for points to be altered. The bug has been fixed.Type of change
expected)
How Has This Been Tested?
Adding the new tests was achieved by running
cmake -G "Unix Makefiles" .followed bymakewhen in the/splashkit-core/projects/cmakedirectory.Testing Checklist
Checklist