Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Gaming > Development Programming Misc > Re: Circle - Sq...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 12 Topic 948 of 1011
Post > Topic >>

Re: Circle - Square Collision Detection

by Miss Elaine Eos <Misc@[EMAIL PROTECTED] > Oct 17, 2007 at 03:24 PM

In article <cmpRi.5736$y21.3058@[EMAIL PROTECTED]
>,
 John Nagle <nagle@[EMAIL PROTECTED]
> wrote:

> Miss Elaine Eos wrote:
> > In article <jKeRi.13363$JD.3817@[EMAIL PROTECTED]
>,
> >  John Nagle <nagle@[EMAIL PROTECTED]
> wrote:
> > 
> >> guitarstrummr@[EMAIL PROTECTED]
 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...)

>     Point to line distance, which is just a dot product, is for an
> infinite line, not a line segment.  It tells you which side of an
> infinite line you're on.  So you have to check all the edge lines.
> (This would be clearer if I could attach an image.)

Even still -- if any two lines are nearer than radius of circle, that's 
an intersection, right?  You don't need the other two to be inside.  
Imagine a circle with a square 45° from it, at the 10:30 position, just 
barely intersecting.  1 lines in, 2 lines out.

Right?  Am I missing something?

-- 
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.
 




 12 Posts in Topic:
Circle - Square Collision Detection
"guitarstrummr@[EMAI  2007-10-15 20:25:18 
Re: Circle - Square Collision Detection
Luc The Perverse <atay  2007-10-16 08:20:43 
Re: Circle - Square Collision Detection
John Nagle <nagle@[EMA  2007-10-17 02:48:47 
Re: Circle - Square Collision Detection
Luc The Perverse <atay  2007-10-17 00:48:52 
Re: Circle - Square Collision Detection
Miss Elaine Eos <Misc@  2007-10-17 14:35:19 
Re: Circle - Square Collision Detection
John Nagle <nagle@[EMA  2007-10-17 08:09:10 
Re: Circle - Square Collision Detection
Miss Elaine Eos <Misc@  2007-10-17 15:24:12 
Re: Circle - Square Collision Detection
John Nagle <nagle@[EMA  2007-10-18 08:47:04 
Re: Circle - Square Collision Detection
Miss Elaine Eos <Misc@  2007-10-19 02:45:55 
Re: Circle - Square Collision Detection
John Nagle <nagle@[EMA  2007-10-21 04:43:06 
Re: Circle - Square Collision Detection
Richard James <IWillGe  2007-10-19 16:59:54 
Re: Circle - Square Collision Detection
Anton <anton.txt@[EMAI  2007-10-28 22:57:11 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 2:13:57 CDT 2008.