• Welcome to the new Internet Infidels Discussion Board, formerly Talk Freethought.

Collision detection with line?

excreationist

Married mouth-breather
Joined
Aug 28, 2000
Messages
2,642
Location
Australia
Basic Beliefs
Probably in a simulation
I was wondering about a mathematical formula to detect the collision with a start X and Y (green), an end X and Y (red), and the player X and Y (cyan). Either the player would have a circle (with a given radius) or it would be a point and the line would have a given thickness (doesn't need curved ends). They might be equivalent?

The purpose is to have a victim (green) in the game that the player (cyan) is chasing. It then generates a random destination and checks if it will collide (or go near) the player on its way to the destination (red).

Screen Shot 2020-04-25 at 1.38.13 pm.png
Screen Shot 2020-04-25 at 1.38.26 pm.png

It should use the least amount of CPU as possible (i.e. try to avoid loops, etc)

Thanks!
 
Back
Top Bottom