Mail Archives: djgpp/1997/10/03/02:30:59
Andrew Deren writes:
>Thanks a lot it works. Would you by any chance also know how to detect a
>rectangle with a circle.
I can think of a few ways to bodge this, but no good solutions jump out
at me. Try comp.graphics.algorithms or rec.games.programmer, they are
the best places for this kind of question...
The most obvious method (very inefficient but I think it will work), is
to subdivide the problem into a couple of different cases. For an
intersection, either the centre point of the circle must lie inside the
rectangle (simple point in box test), or one of the edges of the
rectangle must intersect the circle. To detect that, loop through the
four edges of the rect, measuring the distance from each edge to the
centre of the circle (distance from point to line, see
comp.graphics.algorithms FAQ), and checking whether it is less than the
radius of the circle...
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.
- Raw text -