Commit 23b00b9e90bc862105d9ad59328880fda00c1d94

Authored by Scott Klum
1 parent cef788a8

Added overlap rect utility

openbr/core/qtutils.cpp
... ... @@ -478,5 +478,11 @@ float euclideanLength(const QPointF &point)
478 478 return sqrt(pow(point.x(), 2) + pow(point.y(), 2));
479 479 }
480 480  
  481 +float overlap(const QRectF &r, const QRectF &s) {
  482 + QRectF intersection = r & s;
  483 +
  484 + return (intersection.width()*intersection.height())/(r.width()*r.height());
  485 +}
  486 +
481 487 } // namespace QtUtils
482 488  
... ...
openbr/core/qtutils.h
... ... @@ -89,6 +89,9 @@ namespace QtUtils
89 89  
90 90 /**** Point Utilities ****/
91 91 float euclideanLength(const QPointF &point);
  92 +
  93 + /**** Rect Utilities ****/
  94 + float overlap(const QRectF &r, const QRectF &s);
92 95 }
93 96  
94 97 #endif // QTUTILS_QTUTILS_H
... ...