IntelliPhoto  0.4
IntelliHelper.h
Go to the documentation of this file.
1 #ifndef INTELLIHELPER_H
2 #define INTELLIHELPER_H
3 
4 #include<QPoint>
5 
6 
8 
9 public:
10 
11  static inline float sign(QPoint& p1, QPoint& p2, QPoint& p3){
12  return (p1.x()-p3.x())*(p2.y()-p3.y())-(p2.x()-p3.x())*(p1.y()-p3.y());
13  }
14 
15  static inline bool isInTriangle(QPoint& A, QPoint& B, QPoint& C, QPoint& P){
16  float val1, val2, val3;
17  bool neg, pos;
18 
19  val1 = IntelliHelper::sign(P,A,B);
20  val2 = IntelliHelper::sign(P,B,C);
21  val3 = IntelliHelper::sign(P,C,A);
22 
23  neg = (val1<0.f) || (val2<0.f) || (val3<0.f);
24  pos = (val1>0.f) || (val2>0.f) || (val3>0.f);
25 
26  return !(neg && pos);
27  }
28 };
29 
30 #endif
IntelliHelper::isInTriangle
static bool isInTriangle(QPoint &A, QPoint &B, QPoint &C, QPoint &P)
Definition: IntelliHelper.h:15
IntelliHelper::sign
static float sign(QPoint &p1, QPoint &p2, QPoint &p3)
Definition: IntelliHelper.h:11
IntelliHelper
Definition: IntelliHelper.h:7