Method Proposal: pygame.geometry.Line.closest_point(point, do_clamp=True) #3019
Labels
enhancement
geometry
pygame.geometry
New API
This pull request may need extra debate as it adds a new class or function to pygame
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.The text was updated successfully, but these errors were encountered: