Repository navigation
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
24 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 eb078bc
no error on zero length line
MyreMylar 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| CompileFlags: | ||
| CompilationDatabase: ./.mesonpy-build/ | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -740,3 +740,30 @@ | |
| .. versionadded:: 2.5.3 | ||
|
|
||
| .. ## Line.flip_ab_ip ## | ||
|
|
||
| .. method:: project | ||
|
|
||
| | :sl:`projects the line onto the given line` | ||
| | :sg:`project(point: tuple[float, float], clamp=False) -> tuple[float, float]` | ||
|
|
||
| This method takes in a point and one boolean keyword argument clamp. It outputs an orthogonally projected point onto the line. | ||
| If clamp is `True` it makes sure that the outputted point will be on the line segment (which might not be orthogonal), and if it is `False` (the default) then any point on the infinitely extended line may be outputted. | ||
| This method can be used to find the closest point on a line to the given point. The output is the unique point on the line or line segment that is the smallest distance away from the given point. | ||
|
|
||
|
|
||
| .. figure:: code_examples/project.png | ||
| :alt: project method image | ||
|
|
||
| Example of how it projects the point onto the line. The red point is the point we want to project and the blue point is what you would get as a result. | ||
|
|
||
|
|
||
| .. figure:: code_examples/project_clamp.png | ||
| :alt: project clamp argument image | ||
|
|
||
| Example of what the clamp argument changes. If it is `True`, the point is bounded between the line segment ends. | ||
|
|
||
| WARNING: This method has to have some length or the clamp parameter must be true for it to work and not throw a `ValueError` | ||
|
MyreMylar marked this conversation as resolved.
Outdated
|
||
|
|
||
| .. versionadded:: 2.5.4 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this would need to be updated to 2.5.6 after we have consensus on this PR |
||
|
|
||
| .. ## Line.project ## | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.