问题描述
我的情况
输入:一组矩形
每个矩形由4个双打组成这个:(x0,y0,w,h)
它们不会在任何角度旋转,它们都是正常的矩形,向上/向下和向左/向右对屏幕的尊重
它们是随机放置的 - 它们可能在边缘接触,重叠,或者没有任何接触
我将有几百个矩形
这是用C实现的
我需要找
区域A和B的联合如果重叠
示例
下面的图片包含两个矩形:A,B
A和B重叠
我要找的是两个地区的总面积
<峰; br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<峰; br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<峰; br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<峰; br / >
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<峰; br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<峰; br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<峰; br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA<峰; br />
AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB<峰; br />
AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB<峰; br />
AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB<峰; br />
AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB<峰; br />
AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB<峰; br />
将峰; br />
My situation
Input: a set of rectangles
each rect is comprised of 4 doubles like this: (x0,y0,w,h)
they are not "rotated" at any angle, all they are "normal" rectangles that go "up/down" and "left/right" with respect to the screen
they are randomly placed - they may be touching at the edges, overlapping , or not have any contact
I will have several hundred rectangles
this is implemented in C
I need to find
union of area A and B if overlapped
Example
The image below contains two rectangles: A,B
A and B overlap
What I am looking for is the total area of two region
<br /> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br /> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br /> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br /> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br /> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br /> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br /> AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br /> AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB<br /> AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB <br /> AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB <br /> AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB <br /> AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB<br /> <br />
这篇关于什么是找到重叠的两个区域的总面积的有效算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!