[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Line Collision
gabrielslomka@xxxxxxxxx wrote:
Hey, supose i have a Rect and a Line, i just want to see if the line
intercepts the rect, is that possible somehow in a kind of optimized way
For axis-aligned rectangles you probably want the Cohen-Sutherland
algorithm:
https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm
If all you want to know is whether they intersect or not, you can
just use the first part (calculating the outcodes and ANDing them
together).
--
Greg