3

I need to get the coordinates of the intersections between a Line and a Rectangle.

This code works, but as soon my lines get rotated, It seems a complete mess.

             if (l.intersects(enemy.getLayoutBounds())) {
                Shape collision = Shape.intersect(l, enemy);
                double maxX = collision.boundsInParentProperty().get().getMaxX();
                double minX = collision.boundsInParentProperty().get().getMinX();
                double maxY = collision.boundsInParentProperty().get().getMaxY();
                double minY = collision.boundsInParentProperty().get().getMinY(); }

Is there a better way to do it? I should draw a point on the intersection

here

JonathanDavidArndt
  • 2,518
  • 13
  • 37
  • 49

0 Answers0