Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Line intersects circle

894573Dec 2 2011 — edited Dec 7 2011
Hi,

I have a line and two circles in JavaFX, and I want to know if the line intersects one or more of these circles. I've tried the "intersects" method, but I must not be doing it right, because it doesn't work. At least for me, that is.
Here's my code:
        link.setOnMouseReleased(new EventHandler<MouseEvent>() {
            public void handle(MouseEvent event) {
                if (link.intersects(custCircle.getLayoutBounds())) {
                    lineIntersects = true;
                } else {
                    lineIntersects = false;
                }
                if (link.intersects(piCircle.getLayoutBounds())) {
                    lineIntersects = true;
                } else {
                    lineIntersects = false;
                }
                if (lineIntersects && custCircleIntersects &&
                        piCircleIntersects) {
                    System.out.println("line: intersects all around");
                }
            }
        });
Any help would be greatly appreciated!

Edited by: 891570 on Dec 2, 2011 1:55 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 4 2012
Added on Dec 2 2011
14 comments
3,280 views