Re: Circle - Square Collision Detection



In article <jKeRi.13363$JD.3817@xxxxxxxxxxxxxxxxxxxxxxxxxx>,
John Nagle <nagle@xxxxxxxxxxx> wrote:

guitarstrummr@xxxxxxxxx wrote:
Anyone have any quick and simple code for collision detection between
a circle and a square?

Check the distances between the centers first; eliminate the case
where the circle and square are far enough apart that they can't
possibly touch. After that, do a signed point to line distance calculation
for each edge of the square vs. the center of the circle. If the
signed distance is less than the radius of the circle for all edges,
you have a collision.

If the signed distance is less for ANY edge of the square, right? "All
edges" gives you "square contained in circle" -- right?

(Just checking...)

--
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.
.



Relevant Pages

  • Re: A geometrical problem concerning distances
    ... that the distance from P to one of the two other corners is equal to 40. ... What is the length of the size of the square? ... that the circle of radius 4 is at the origin, ... We find by this check that only s_1 is a valid solution. ...
    (sci.math)
  • Re: Ten points in a square
    ... If you place 10 distinct points in a square of side 1, ... two points will have distance no more than sqrt/3. ... It is 0.421..., which follows from the packing of ten unit circles, proven ... It's not clear to me that the 10 circle packing configuration answers ...
    (sci.math)
  • Re: plot
    ... Dirk Vdm ... ^2 + ^2 is the square of the distance between ... distance is greater than some number, ... outside the circle. ...
    (sci.math)
  • Re: Circle - Square Collision Detection
    ... where the circle and square are far enough apart that they can't ... don't bother with the square roots. ... so a positive signed distance will always indicate "outside". ...
    (comp.games.development.programming.misc)
  • Re: Circle - Square Collision Detection
    ... John Nagle wrote: ... where the circle and square are far enough apart that they can't ... so a positive signed distance will always indicate "outside". ...
    (comp.games.development.programming.misc)

Loading