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,5 +478,11 @@ float euclideanLength(const QPointF &point)
478 return sqrt(pow(point.x(), 2) + pow(point.y(), 2)); 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 } // namespace QtUtils 487 } // namespace QtUtils
482 488
openbr/core/qtutils.h
@@ -89,6 +89,9 @@ namespace QtUtils @@ -89,6 +89,9 @@ namespace QtUtils
89 89
90 /**** Point Utilities ****/ 90 /**** Point Utilities ****/
91 float euclideanLength(const QPointF &point); 91 float euclideanLength(const QPointF &point);
  92 +
  93 + /**** Rect Utilities ****/
  94 + float overlap(const QRectF &r, const QRectF &s);
92 } 95 }
93 96
94 #endif // QTUTILS_QTUTILS_H 97 #endif // QTUTILS_QTUTILS_H