Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder5.news.weretis.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Gavino" Newsgroups: comp.lang.java.programmer Subject: Re: Programming question determining two circle's relation Date: Sat, 30 Apr 2011 18:33:28 +0200 Lines: 27 Message-ID: <922rujFrlgU1@mid.individual.net> References: <892252a0-e31d-426b-8f47-d37c0b2ec364@17g2000prr.googlegroups.com> <14270bba-4ef7-4144-bba3-e0a1bb943fca@a21g2000prj.googlegroups.com> <2bc6aa50-5730-4057-b016-3a2b7154f0e9@f15g2000pro.googlegroups.com> <922ph0Fa0tU2@mid.individual.net> <7e45f31e-09cc-4bd8-90d1-aa76782bf9a5@d26g2000prn.googlegroups.com> X-Trace: individual.net RbBLQWq/DA3u79WPshKqcAZga9CPoIPv2/rtECCVa7mnGjPwqP Cancel-Lock: sha1:gZ/yKWGbNEsOkyXH4x0NbXFFTt4= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3381 "byhesed" wrote in message news:7e45f31e-09cc-4bd8-90d1-aa76782bf9a5@d26g2000prn.googlegroups.com... >No, it's totally correct. >In the source code, distance means the distance between center of two >circles. >So, distance = Math.sqrt((x0-x1)^2 + (y0-y1)^2) Yes, but in that version of your code you didn't have the sqrt. >Here is conditions for determining positions of two circles. >Contains: d <= |r1 - r2| >Overlaps: |r1 - r2| < d < r1 + r2 So you are defining c1.contains(c2) to include the case where c1 is inside c2? That's a strange definition of containment. Conversely, your definition of 'overlaps' gives false when one circle is inside the other, which I would expect to count as overlapping. Still, it's your function and you can define it how you like (but if you are producing this for someone else, you'd better be sure the definition matches what is expected).