summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qpoint.h
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2012-08-02 07:18:35 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-26 00:09:14 +0100
commite335fb7254ad6c2ce08eda0d092ea524a302c2e0 (patch)
tree0d6eaa362988c4101d0e210dd97ffa0b44f4beb6 /src/corelib/tools/qpoint.h
parent5f481c98de872e7c58a17f090be697c241b9f256 (diff)
Add static dotProduct methods to the QPoint(F) classes
Change-Id: I66ac9433b74341a83569a60038ea2f7a025e81b1 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/corelib/tools/qpoint.h')
-rw-r--r--src/corelib/tools/qpoint.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index b6446e8c9f..cb7a5ecd23 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -76,6 +76,8 @@ public:
inline QPoint &operator/=(qreal divisor);
+ Q_DECL_CONSTEXPR static inline int dotProduct(const QPoint &p1, const QPoint &p2);
+
friend Q_DECL_CONSTEXPR inline bool operator==(const QPoint &, const QPoint &);
friend Q_DECL_CONSTEXPR inline bool operator!=(const QPoint &, const QPoint &);
friend Q_DECL_CONSTEXPR inline const QPoint operator+(const QPoint &, const QPoint &);
@@ -153,6 +155,9 @@ inline QPoint &QPoint::operator*=(double factor)
inline QPoint &QPoint::operator*=(int factor)
{ xp = xp*factor; yp = yp*factor; return *this; }
+Q_DECL_CONSTEXPR inline int QPoint::dotProduct(const QPoint &p1, const QPoint &p2)
+{ return p1.xp * p2.xp + p1.yp * p2.yp; }
+
Q_DECL_CONSTEXPR inline bool operator==(const QPoint &p1, const QPoint &p2)
{ return p1.xp == p2.xp && p1.yp == p2.yp; }
@@ -233,6 +238,8 @@ public:
inline QPointF &operator*=(qreal c);
inline QPointF &operator/=(qreal c);
+ Q_DECL_CONSTEXPR static inline qreal dotProduct(const QPointF &p1, const QPointF &p2);
+
friend Q_DECL_CONSTEXPR inline bool operator==(const QPointF &, const QPointF &);
friend Q_DECL_CONSTEXPR inline bool operator!=(const QPointF &, const QPointF &);
friend Q_DECL_CONSTEXPR inline const QPointF operator+(const QPointF &, const QPointF &);
@@ -330,6 +337,11 @@ inline QPointF &QPointF::operator*=(qreal c)
xp*=c; yp*=c; return *this;
}
+Q_DECL_CONSTEXPR inline qreal QPointF::dotProduct(const QPointF &p1, const QPointF &p2)
+{
+ return p1.xp * p2.xp + p1.yp * p2.yp;
+}
+
Q_DECL_CONSTEXPR inline bool operator==(const QPointF &p1, const QPointF &p2)
{
return qFuzzyIsNull(p1.xp - p2.xp) && qFuzzyIsNull(p1.yp - p2.yp);