Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.news-service.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!209.197.12.242.MISMATCH!nx01.iad01.newshosting.com!209.197.12.246.MISMATCH!nx02.iad01.newshosting.com!newshosting.com!69.16.185.21.MISMATCH!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 30 Apr 2011 04:08:29 -0500 Date: Sat, 30 Apr 2011 02:08:35 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Programming question determining two circle's relation References: <892252a0-e31d-426b-8f47-d37c0b2ec364@17g2000prr.googlegroups.com> In-Reply-To: <892252a0-e31d-426b-8f47-d37c0b2ec364@17g2000prr.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 27 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 75.8.126.96 X-Trace: sv3-B6ih7hJnvYI5SjTBbt/IDvrpkUxdUw/WWYMdx749++8KyK5ciLkHG+EdlulV6DBVTBQtNbktPAPsMen!RZ9WBqrX1e1pzmjoaGcq8weKmuH5sUF0JGbHVeEspsbgGd+k+vhAay3IEgSjO52x8+koOikLlxZe!2qa8lfJxPRGCtxZiNvuMcMT8pGuntTtDk43JA9DJAVg= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2054 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3376 On 4/30/2011 1:33 AM, byhesed wrote: ... > - double distance = Math.sqrt(Math.pow(circle.x - getX(), 2.0) + > Math.pow(circle.y - getY(), 2.0)); ... > public boolean contains(double x, double y) { > double distance = Math.pow(getX() - x, 2.0) + Math.pow(getY() - y, > 2.0); > if (distance<= radius) > return true; > else > return false; > } ... I suggest comparing the distance calculation you actually use in the contains(double x, double y) method to the distance calculation you described. If you have a calculation you need to do a lot, why not write and test a separate method to do it, rather than writing the calculation in-line repeatedly? What is the contains(Circle2D circle) method supposed to return if circle contains this? Patricia