问题描述
是否有任何已知的方法来计算两个矩形之间的交集矩形?我的意思是,如果矩形 A 由 (x1,y2, x2,y2) 定义,B 由 (x3,y3, x4,y4) 定义,我该如何计算相交矩形 C (x5,y5, x6,y6)?
Is there any known approach to compute the intersection rectangle between two rectangles? I mean if the rectangle A is defined by (x1,y2, x2,y2) and B by (x3,y3, x4,y4), how do I compute the coordinates of the intersection rectangle C (x5,y5, x6,y6)?
谢谢.
推荐答案
多边形相交的一般问题在这里详细解释:http://davis.wpi.edu/~matt/courses/clipping.顺便说一句,具有多种编程语言绑定的任务的最佳库之一是 GPC - 通用多边形裁剪库:http://www.cs.man.ac.uk/~toby/alan/software
The general problem of intersecting polygons is explained in detail in here: http://davis.wpi.edu/~matt/courses/clipping . Incidentally, one of the best libraries for the task, with bindings for several programming languages, is GPC - the General Polygon Clipper library: http://www.cs.man.ac.uk/~toby/alan/software
这篇关于矩形交点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!