Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Java 3D / November 2003

Tip: Looking for answers? Try searching our database.

a simple 2d question...

Thread view: 
Dominik Kaspar - 18 Nov 2003 22:03 GMT
Hello

I want to catch mouse clicks on drawn lines and was dumbfound by the
Line2D.intersects method.

My code looks like this:
   Line2D.Double l = new Line2D.Double(0, 0, 100, 100);
   if(l.intersects(49, 49, 51, 51)) System.out.println("1");
   if(l.intersects(35, 35, 37, 37)) System.out.println("2");

The line (0,0)-(100,100) definitely doesn't intersect with the
rectangle (35,35)-(37,37). But why the hell does the above code give
the output "1" and "2"?!

I hope somebody can eliminate my confusion.
Dominik
Dominik Kaspar - 19 Nov 2003 16:20 GMT
Hmm, bad example...
Why does the following give the output "1"?
   Line2D.Double l = new Line2D.Double(120, 120, 240, 240);
   if(l.intersects(140, 190, 150, 200)) System.out.println("1");

Dominik

> Hello
>
[quoted text clipped - 12 lines]
> I hope somebody can eliminate my confusion.
> Dominik
Sujatha S G - 20 Nov 2003 03:11 GMT
The Output is correct, May be you are thinking that you are drawing a
horizontal line. But you are drawing a line in 45 deg angle. And the
rectangle points you are giving will definitely intersect. may be you can
checn in "mspaint" by drawing this lines and rectangles.

> Hmm, bad example...
> Why does the following give the output "1"?
[quoted text clipped - 19 lines]
> > I hope somebody can eliminate my confusion.
> > Dominik


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.