| Author |
Rectange Problem
|
ManChun Lam
Greenhorn
Joined: May 04, 2008
Posts: 28
|
|
|
Assuming I know the 4 coordinates of any rectange. What is the quickest way to check if any 2 rectangles are connected with each other (adjacent)? Thank you.
|
 |
Charles Lyons
Author
Ranch Hand
Joined: Mar 27, 2003
Posts: 836
|
|
Sounds like a homework problem. What's your thinking so far? Just to clarify, by "adjacent" you mean that two rectangles will touch each other on exactly one side (discounting the possibility of touching vertices but not edges) and do not overlap?
|
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
|
 |
Bill Shirley
Ranch Hand
Joined: Nov 08, 2007
Posts: 457
|
|
Are you allowed to use java.awt.Rectangle, or are you trying to deal with the geometry from scratch. Draw each case on paper, and determine how you would test the geometry for that. Are you using integers or decimals? Also, it's good to review faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
|
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
|
 |
Joseph Fisher
Greenhorn
Joined: Jun 09, 2008
Posts: 5
|
|
|
If you know the coordinates, wouldn't you know what lines fell on what axis? That would tell you which lines connect,right?
|
 |
 |
|
|
subject: Rectange Problem
|
|
|