BEFORE:

AFTER:

```
inline static bool rectOverlap(const float6& r1, const float6& r2)
{
// The rectangles do not overlap at all
if ( r2.x > r1.z || r2.z < r1.x ||
r2.y > r1.w ||
r2.w < r1.y ) return false;
else {
float overlap_x = std::min(r2.z,r1.z) - std::max(r2.x,r1.x);
float overlap_y = std::min(r2.w,r1.w) - std::max(r2.y,r1.y);
float area_overlap = overlap_x * overlap_y;
float area_r1 = (r1.z-r1.x) * (r1.w-r1.y);
float area_r2 = (r2.z-r2.x) * (r2.w-r2.y);
// The rectangles overlap by less than 75% of either's area
if ((area_overlap < 0.25*area_r1) && (area_overlap < 0.25*area_r2)) return false;
// The rectangels overlap
return true;
}
}
```

## Discussions

## Become a Hackaday.io Member

Create an account to leave a comment. Already have an account? Log In.