-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[rshapes]Circle line collision function #4018
Conversation
@kai-z99 Thanks for the addition! I try to minimize this kind of functions on raylib, they probably belong to a physics engine more than raylib but adding this one for convenience. Thanks! |
@raysan5 Thanks! I was planning to make a polygon to circle collision function, would that be appropriate? I've created a few games in raylib so far and I always felt it would be super handy as opposed to making a custom one for the game or introducing physics lib. |
Added a function to check collision between a line defined by p1, p2 and a circle defined by its position and radius. This code is tested in https://github.com/kai-z99/raylib/blob/circleLineDev/examples/shapes/shapes_collision_area.c
This function is intended to a standalone collision detection function as well as possibly a helper function for a polygon-circle collision function.
The algorithm is based on https://www.jeffreythompson.org/collision-detection/line-circle.php
It is also similar to this one: #4000 (which is closed)