How to find intersection rectangle(points) of instersecting rectangles

扶醉桌前 提交于 2019-12-31 05:38:06

问题


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(get 2 points where these rectangles intersect).

Prgramming language does not matter. May be pseudo code.

PS: Rectangles are parallel to the OXY.


回答1:


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



来源:https://stackoverflow.com/questions/13670167/how-to-find-intersection-rectanglepoints-of-instersecting-rectangles

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!