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

Method Proposal: pygame.geometry.Line.closest_point(point, do_clamp=True) #3019

Open
damusss opened this issue Jul 25, 2024 · 5 comments
Open
Labels
enhancement geometry pygame.geometry New API This pull request may need extra debate as it adds a new class or function to pygame

Comments

@damusss
Copy link
Member

damusss commented Jul 25, 2024

The Line object has not been ported yet, but for the time it will, I propose to add the method in the title.

The method returns the closest point on the line relative to another point. The math for it isn't super straight forward, and unless you studied that somehow you probably need to search it online, that's why I think it should be added.

The do_clamp parameter controls weather the endpoints are ignored. The "default" math returns a point that can exceed A and B, but this could be what the user wants, so it could be optionally clamped.

@damusss damusss added enhancement New API This pull request may need extra debate as it adds a new class or function to pygame geometry pygame.geometry labels Jul 25, 2024
@bilhox
Copy link
Contributor

bilhox commented Oct 13, 2024

I didn't understand what the feature does, it might be more elaboration and a schema.

@MrRedstone058
Copy link
Contributor

MrRedstone058 commented Oct 19, 2024

The Line object has not been ported yet, but for the time it will, I propose to add the method in the title.

The method returns the closest point on the line relative to another point. The math for it isn't super straight forward, and unless you studied that somehow you probably need to search it online, that's why I think it should be added.

The do_clamp parameter controls weather the endpoints are ignored. The "default" math returns a point that can exceed A and B, but this could be what the user wants, so it could be optionally clamped.

to understand what you're saying, is it basically finding the point in a line that is directly perpendicular to the point? (in the case of do_clamp = false, the closest point follows the gradient of the original line)?

@damusss
Copy link
Member Author

damusss commented Oct 19, 2024

@bilhox @MrRedstone058 I drawed what this method is supposed to do:
image
Now, with do_clamp = False, we have:
image
and with do_clamp = True, we have:
image

@MrRedstone058
Copy link
Contributor

yup, just as i thought. i do not know the best way to do the math for this, but i can try to work it out as a base

@bilhox
Copy link
Contributor

bilhox commented Oct 19, 2024

After a discussion, we agreed to rename this function to Line.project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement geometry pygame.geometry New API This pull request may need extra debate as it adds a new class or function to pygame
Projects
None yet
Development

No branches or pull requests

3 participants