How to find intersection rectangle(points) of instersecting rectangles

前端 未结 1 956
南旧
南旧 2021-01-28 02:16

If I have two instersecting rectangles[(x1,y1)(x2,y2)][(x3,y3)(x4,y4)] described by two verticles. How to find a rectangle which is effect of their intasection(

相关标签:
1条回答
  • 2021-01-28 03:01

    You could use Rectangle.intersection:

    Rectangle intersection = rectangle1.intersection(rectangle2);
    

    2 of the vertices of the resulting rectangle will be the intersection points. You can use Rectangle.contains to determine the common points.

    See: Rectangle Intersection Source

    0 讨论(0)
提交回复
热议问题