-
-
Notifications
You must be signed in to change notification settings - Fork 190
Implemented the Line.project #3402
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
Open
XFajk
wants to merge
23
commits into
pygame-community:main
Choose a base branch
from
XFajk:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
22ccf84
implemented the Line.project method with all the tests and docs
XFajk e2001dd
added the doc string to the method in C
XFajk 193071a
optimized the Line.project method made it METH_FASTCALL and removed s…
XFajk ea76d39
made the docs more clear, improved the images
XFajk 44ab4fc
Update docs/reST/ref/geometry.rst
XFajk cd9c648
Update docs/reST/ref/geometry.rst
XFajk 896f7b2
Update docs/reST/ref/geometry.rst
XFajk ed8af87
added "/" to the stub file to indicate that the first arg is position…
XFajk bfe2698
added one more test case fixed the stub
XFajk a291329
made a small change to the stub
XFajk 317719e
fixed a bug in the Line.project method
XFajk e6c1f8c
remade the method to be VARARGS insted of FASTCALL
XFajk 383741f
added proper error handling and and reflected that in the docs and tests
XFajk f7178f6
removed one mistake made
XFajk e89deaa
Update line.c
XFajk d06b383
Update line.c
XFajk 81dc704
Delete .clangd unimportant file
XFajk 70dc960
Update buildconfig/stubs/pygame/geometry.pyi
XFajk 82c43c9
Update geometry.rst
XFajk 32ae369
Update src_c/line.c
XFajk 1a8d9f6
Update src_c/line.c
XFajk 2401414
Update src_c/line.c
XFajk 4194dce
Fix typo in variable name for squared line length in _line_project_he…
XFajk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
Oops, something went wrong.
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.
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.
API discussion point: is the current implementation better, or would it be better if the clamp and no clamp behaviour was identical when
squared_line_length == 0.0
? It seems like that essentially becomes "project a point onto a point" where there should be no notion of clamping because there are no two distinct points.Me personally I don't have much of an opinion either way but I'd like to get other reviewers say on this front, for now I am not asking you to change anything here.
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.
I believe it should not error when the line has no length in any case. actually, it makes less sense to error when it is not clamped. there is one good available spot to project the point, which is the only one. The clamped-0-length behavior is the one that actually has an "exception" since the method doesn't know in what direction to project, resulting in the only valid spot.
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.
No one would want their code to error because while the mouse was dragging or while the objects overlapped, the line got a length of zero. If you really do care about it working differently in that case, checking it before hand is straight forward.
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.
I agree that these edge case errors should be avoided when possible.
For the 0-length non-clamped projection, the method could possibly either return the line point or the argument point. (Clamped returns the line point.) I think returning the line point is accurate though.