多少钱,两个矩形重叠?矩形、多少钱、两个

2023-09-11 00:25:57 作者:aヾ爺獨ぷ゛愛╱мèヾ

我有两个矩形a和b与它们的侧面平行于坐标系的轴。我有自己的坐标为X1,Y1,X2,Y2。

I have two rectangles a and b with their sides parallel to the axes of the coordinate system. I have their co-ordinates as x1,y1,x2,y2.

我想确定,他们不仅重叠,但是有多少,它们重叠?我想弄清楚,如果他们真的是相同的矩形给予或采取一点回旋的余地的。那么,它们的面积95%相同的?

I'm trying to determine, not only do they overlap, but HOW MUCH do they overlap? I'm trying to figure out if they're really the same rectangle give or take a bit of wiggle room. So is their area 95% the same?

任何帮助,在计算的重叠%?

Any help in calculating the % of overlap?

推荐答案

该公式交集将是

SI= Max(0, Min(XA2, XB2) - Max(XA1, XB1)) * Max(0, Min(YA2, YB2) - Max(YA1, YB1))

那么工会就会 S = SA + SB-SI

最后,该比例将 SI / S