COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Testing Intersection with A Rectangle(2D) w/No Area

• Email
• Follow

```How do I test a rectangle for intersection with another rectangle which has
no area, ie where the y1 and y2 co-ords are the same? All the intersect
methods from awt.geom.Rectangle2D.* and awt.geom.Area seem to test for
intersection with the interior of the rectangle, but that always returns
false for a degenerate rect which is equivalent to a line. Do I have to
create that equivalent line and test intersectsLine, or is there a better
way?

```
 0

See related articles to this posting

```
Aaron Davies wrote:
>
> How do I test a rectangle for intersection with another rectangle which has
> no area, ie where the y1 and y2 co-ords are the same? All the intersect
> methods from awt.geom.Rectangle2D.* and awt.geom.Area seem to test for
> intersection with the interior of the rectangle, but that always returns
> false for a degenerate rect which is equivalent to a line. Do I have to
> create that equivalent line and test intersectsLine, or is there a better
> way?

Rectangle r = new Rectangle( 1,0,10,10);
Rectangle s = new Rectangle( 0, 5, 11, 0);
if ( r.intersects(s) ) {
System.out.println( "r intersects s");
}
if ( s.intersects(r) ) {
System.out.println( "s intersects r");
}
Rectangle q = r.intersection(s);
System.out.println( "intersection: "+q);

When this is executed, it verifies that r and s intersect, regardless of
whether you use r.intersects(s) or s.intersects(r). And s is a
degenerate rectangle with no height. Are you sure your rectangles
actually intersect?
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94  (206)544-5225
```
 0

1 Replies
597 Views

Similar Articles

11/30/2013 9:02:57 PM
page loaded in 52721 ms. (0)

Similar Artilces:

Just bought a used toughbook 48, and apparently it was a "Department of Defense" computer, boots up to windows 2000 just fine if shut down properly, but if you close the lid or put it on standby a msg appears saying something along the lines of it being in use and is locked, press ctrl alt delete to enter password, only administrator can unlock..etc. I have to pull the battery for it to boot back up properly. Any way to remedy this? Also, the msg that pops up about it being a department of defense system and all access can be monitored by the U.S. government, what's all tha

HomeDaemon w/ SwitchLinc?
I've been trying out Karl Denninger's HomeDaemon to replace Misterhouse (I'm just not using much of MH) and it seems to work well. Only problem...I've invested in SwitchLInc dimmers and I can't get it to control them! Should this work? If someone has it working, please post your events file....I may have missed something in the docs. Thanks! dp

redirects w/ js
I have a site with PHP code that I need to have a js function to redirect to another page or site. I am just trying to learn JS and need a starting palce. Would this be difficult? Magic-chef wrote: > I have a site with PHP code that I need to have a js function to > redirect to another page or site. I am just trying to learn JS and need > a starting palce. Would this be difficult? Difficult, no, just set a new value for the window.location object. But its probably the wrong way to do things, redirection using JavaScript is almost always suboptimal compared to redirection us

WinVice 1.15 w/ WinXP crash
Someone has any idea why WinVICE 1.14 works just fine with Win XP SP1 (Finnish version), but 1.15 just fails when attempting to boot z80 (no matter which version, all cpms just crash; 'says' something like that memory can't be write/only and launches VC 6 debugger, which helps me a lot with M/L; looks like a code went into a limbo). -14 Doesn't have a proper support for drives 10 and 11, that's why asking for info for -15. Cheers, Sami Nikkinen --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.766 / Virus

Supernews is S-----L-----O-----W
A few weeks ago, on the "recommendation" of a frequent participant in these discussions who described it as being "fast" I subscribed to Supernews. What I'm finding is that Supernews is very slow, taking in the range of five to ten seconds to determine if there are any new postings in each of my subscribed-to newsgroups. My "Macintosh" subscription includes nine newsgroups, and I typically wait in the range of a minute before Supernews has completed its search. Other than the slowness Supernews has been fine and I can now post to several newsgroups whi

Problems w/ CD reader on G4
Just upped a G4 OS from OS 9 to OS 10.3 for a friend This is a early model G4 without a CD burner Everything seems great with one exception: The Cd's I burn on my Mac G4 1000mghrz are presenting reading problems on my freinds Mac. I use the latest version of Toast and others have had no problems w/ CD's I have burned,... (both PC and Mac) Is there maybe a updater for the (driver/firmware?) for the CD drive in this Mac,... which I believe is about 500 mghrz or 450. Can you clean the Drive,..? I burn sometimes as Data and also as Disc images but both seem to be presenting problems when reading Thanks Kevin Duggan -- http://www.soundclick.com/kevinduggan http://www.kevsblues.com Kevin Duggan wrote: > Just upped a G4 OS from OS 9 > to OS 10.3 for a friend > > This is a early model G4 without a CD burner > > Everything seems great with one > exception: > > The Cd's I burn on my Mac G4 1000mghrz > are presenting reading problems on my freinds > Mac. > > I use the latest version of Toast and > others have had no problems > w/ CD's I have burned,... (both PC and Mac) > > Is there maybe a updater

Eudora 5.2.1 weirdness w / OS X 10.3.2
I get the regular Evil Beach Ball in Eudora, now that I've installed 10.3.2. I last had 10.2.8, and this Eudora worked fine w/ that version of OS X. I find it always hard to tell if Eudora has been updated for a new OS release, as its developers, IMHO, simply "update" Eudora to keep a regular income stream coming, regardless of the previous rev's compatibility. Does anyone else see this or similar issue with Eudora under 10.3.x? Thanks, -- DaveC me@privacy.net This is an invalid return address Please reply in the news group On Thu, 15 Jan 2004 15:41:22 -0800, DaveC wrote (in article <0001HW.BC2C6522001A83A4F03055B0@news.individual.net>): > I get the regular Evil Beach Ball in Eudora, now that I've installed 10.3.2. > I last had 10.2.8, and this Eudora worked fine w/ that version of OS X. Details: randomly, the beach ball appears, and I can't do anything in Eudora. I can switch apps, and use other apps normally during this period (typically 10-20 seconds). Then I can use Eudora for awhile (less than 30 seconds), then not. Ideas? Thanks, -- DaveC me@privacy.net This is an invalid return address Please reply in the news

Transferring MP3s and JPGs to phone w/Mac?
Is there anyway to get ring tone MP3s and image files to and from my Motorola V3 via USB? No bluetooth on my PowerBook. If I get a BT dongle, will this allow me to accomplish this? Thanks, -- John English In article <0001HW.C1BC160A0008EE97F02845B0@news.readfreenews.net>, John E. <incognito@yahoo.com> wrote: > Is there anyway to get ring tone MP3s and image files to and from my > Motorola V3 via USB? No bluetooth on my PowerBook. If I get a BT > dongle, will this allow me to accomplish this? If your carrier is Verizon, there's no way to do it directly. Yo

Newtwork w/ OS 8.6 & XP: Help?
Would appreciate constructive comments on how to net work with two PC's running XP on my home network. Briefly, I have a Linksys/Comcast Router/Gateway, with the PC's running Window XP on a wireless LAN through the router, and my OLD Mac PPC G3 233 (running OS 8.6- yes, I know, VERY OLD!!!) hardwired to the Ethernet port. Trouble is, I can't get my Mac to see the PC's and the PC's to see the Mac. Want to be able to swap files between each.... Tried playing with most of the settings with no positive result. ANyone have any comments and advice as to how to get these

Question abt overclocking a B&W G3
the B&W has jumpers on the motherboard for setting clock speed. i have a 400 MHz machine and the jumpers allow for a 500 MHz setting. Anyone ever done this? a 25% increase in spped just by changing a jumper seems great but are there drawbacks like overheating or instability? i would think that the Apple engineers wouldn't have made it so easy if there was any danger in it. i'm a relatively poor guy and i don't want to fuck up my otherwise ok machine, but how about some informed opinions? TIA Nearly Normal Jimmy <mac_loony@yahoo.com> writes in article <030420051803532151%mac_loony@yahoo.com> dated Sun, 03 Apr 2005 18:03:53 -0700: >the B&W has jumpers on the motherboard for setting clock speed. i have >a 400 MHz machine and the jumpers allow for a 500 MHz setting. > >Anyone ever done this? a 25% increase in spped just by changing a >jumper seems great but are there drawbacks like overheating or >instability? CPU manufacturers use their best template when making chips. But due to randomness in the process, some chips turn out better than others. Each one is tested at different clockspeeds to see where it's stable (runs

ntpdate synchronization b/w two ntpservers
BismillahirRehmanirRahim Hi Sun Admins, may i know is it possible to synchronize time using ntpdate b/w two ntpservers ? the problem is that our servers are unable to synchronize with our ntp server as its behind the firewall. As far as i know, ntpdate uses port 123 UDP to connect to ntp Server the source port used by the client is choose randomnly >1023. so ntp server reply to ntp client request to that randomnly choose port. The problem is that we have bidirectional firewall. and they wont open firewall for randomn ports. the destination port should be specified or the range...;03516e05-83a7-430d-9415-1d8f7a6ff446@d4g2000prg.googlegroups.com>, Salman <hudamuslim@gmail.com> wrote: > BismillahirRehmanirRahim > > Hi Sun Admins, > > may i know is it possible to synchronize time using ntpdate b/w two > ntpservers ? > > the problem is that our servers are unable to synchronize with our ntp > server as its behind the firewall. > > As far as i know, ntpdate uses port 123 UDP to connect to ntp Server > > the source port used by the client is choose randomnly >1023. > > so ntp server reply to ntp client request

Arithmetic expressions w. recursive descent parser?
Hi! I'm new to parsing and compiling and just starting out here. I'm trying to make a simple java program to parse arithmetic expressions. To keep it simple, only integers are used in the expression, together with * / + - ( ) as terminals. I want the parser to be a predictive recursive descent parser, with 1 lookahead. The problem is that I cant get the implementation right with +,- in combination w. numbers starting w. + or -, eg. -45, +3, etc. I would appreciate any help, pointers, tips, on how to get the + and - operator correctly implemented with numbers that could start...())) { number += getNumber(); return Double.parseDouble(number); } else { throw new ExpressionException("Expected a number!"); } } private int getNumber() { String number = new String(); while (isDigit(current())) { number += current(); try { nextToken(); } catch(ExpressionException e) { /* if we get here, we have at least one digit */ return Integer.parseInt(number); } } return Integer.parseInt(number); } /Regards B.Mildh bmildh@linuxmail.org wrote: > The problem is that I cant get the implementation right with +,- in > combination w

What is best way to resize (shrink) a picture w/o degrading it?
When I look at a picture I am working with and reduce the zoom (1:2) it still looks good, but as soon as I resize it by 50% it looks real pixelated.....looks like crap. Usually it's the other way around. Zoom looks worse than actually resizing it, but this is not true with this. I have always used "Smart size" and I don't know the difference in the other options that i have from the dropdown menu (bilinear resample, bicubic resample, Pixel resize) cho@noho.educomnetws wrote: > When I look at a picture I am working with and reduce the > zoom (1:2) it still looks good, b

S-L-O-W MS Word V.x --- Why?
Microsoft Word V.x (with all the latest updates installed) is incredibly slow on a particular 800 MHZ eMac. The very same version of Word doing exactly the same tasks runs reasonably on two different 400 MHZ iMacs. The eMac and the iMacs all have 256 MB of RAM. All of the computers involved are running OS-X 10.3, and all of them have the latest updates, both to the system software and to Microsoft Office installed As an example, when four 20 page documents are concurrently open it takes about 5 to 10 seconds on the eMac to switch the active window from one document to another. The sam

Copying Playlists to Palm LifeDrive -------- S --- L --- O --- W --------
Last night, and for the first time, I uploaded a playlist from iTunes to my Palm LifeDrive. The LifeDrive was connected to my PowerBook via the cable, the upload was made with the Mark/Space Conduit for iTunes, and the playlist included 16 selections with a total playing time of just one hour. The upload time was just a snitch over two hours. The same playlist will upload to my iPod shuffle in just a couple of minutes. Is this normal or have I perhaps done something incorrectly? Many thanks in advance for advice/suggestions/tomatoes..... -- James L. Ryan -- TaliesinSoft On 2005-11-0

Excruciatingly S-L-O-W Internet Access--Why?
; -- Earl W. Stevick TaliesinSoft wrote: > Here's a happy ending to the problem I described above.... > > Upon investigation my sister was using DNS numbers that were furnished by > AT&T and I was using DNS numbers furnished by OpenDNS. I changed my sister's > DNS numbers to be the same as mine and her internet access times are now as > good as mine. Interesting! I put a DNS server on my own LAN, for a slight improvement in speed. -- Wes Groleau You're all individuals! Yes, we're all individuals! You're all different...: > I think this is a case of "to each his own". My network isn't as > complex as JR's, so my /etc/hosts file is good enough for me. If I had > more devices and heterogeneous OS, then some form of NIS or DNS would > make sense. I have 3 only network devices: two computers and a router (the Macs see the printer on the USB via some internal Mac magic). So I just edit my hosts file on each computers. I don't know what niload is though. The system automatically sees changes to the hosts file. -- W. Oates In article <

Retaining song titles when recording w/ Toast 6.0.9
When I try to make a recording with Toast, and have all the song titles typed in Toast, I lose the titles when I make a CD. The tunes on the resulting CD are just named Track 1, Track 2, etc. Any way to retain these titles? Thx. T-L In article <020520050827568333%Trent-Lion@No.Name.com>, Trent-Lion <Trent-Lion@No.Name.com> wrote: > When I try to make a recording with Toast, and have all the song titles > typed in Toast, I lose the titles when I make a CD. The tunes on the > resulting CD are just named Track 1, Track 2, etc. > Any way to retain these titles? > Thx.

javascript + vml
I am creating/modifying VML using javascript. I create a VML object <polyline>. <polyline> has an attribute called "points". i create the polyline like so: var line = document.createElement('v:polyline'); i set the "points" attribute like so: line.setAttribute('points','0,0,10,10,20,0'); now i check to see if setAttribute worked by doing a getAttribute (it works) alert(line.getAttribute('points')); this returns: 0,0,10,10,20,0 once i attach the polyline to document, the trouble starts: document.body.appendChild(line); now i

Visitor pattern w/ separate iterator (like fold) need ideas
I am pursuing an idea I have had for a while, which I call the VIT triple, for visitor, iterator, and tree. The name, besides being descriptive, is designed to invoke memories of the MVC (model, view, and controller) design pattern from Smalltalk. This is a design pattern for applying the visitor pattern to AST's (and similar trees, such as parse trees). The key "innovation" in the pattern is the separation of the iterator from the visitor. By separating the iterator from the visitor it is easier to make each reusable. The model matches roughly a design methodology used in m

How to store DVDs made w/ Popcorn/Toast for later duplication
Is there a usual way of storing DVDs made w/ Popcorn & Toast for later duplication? I have been keeping them on a separate Firewire HD, making a folder for each DVD and putting the VIDEO_TS folder in it. When I want to copy that DVD, I drag its VIDEO_TS folder to Popcorn or Toast. For a couple of DVDs, not really knowing what I was doing, I saved as Disc Image, stored those images, and have used them for duplication. Do folks generally store VIDEO_TS folders or disc images on hard drives, or is inserting a DVD disc and duplicating from that the usual way? Thx. T-L