Java Docs say the class method Line2D:
public boolean intersects(double x, double y, double w, double h)
if the inside intersects the inside of a given rectangular region. To do this, he uses the method , but the calculations to accurately determine this intersection are very expensive. ShapeShape.intersects()
, Shapes true, Shape.
itersectsLine(), intersects() intersectsLine() . linesIntersect() 298
Area , Shape, , . :
boolean intersectionExists(Shape shape1, Shape shape2) {
Area area1 = new Area(shape1);
area1.intersect(new Area(shape2));
return !area1.isEmpty();
}
:
public static void main(String[] args) {
Line2D line1 = new Line2D.Double(464.9298111721873, 103.78661133348942, 684.8391765253534, -155.44752172931908);
Line2D line2 = new Line2D.Double(414.16903384086487, 163.62456359144306, 393.52528378472925, 187.95988300984624);
System.out.println("Lines intersect? " + intersectionExists(line1, line2));
}
:
Lines intersect? false