多少钱,两个矩形重叠? [英] How much do two rectangles overlap?

查看:117
本文介绍了多少钱,两个矩形重叠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个矩形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

这篇关于多少钱,两个矩形重叠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆