mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-14 12:20:32 +02:00
Integrated Polygon Test
Use calculate traingles and the isInPolygon with theese triangles, this is done because of performance reasons
This commit is contained in:
@@ -2,17 +2,20 @@
|
||||
#define INTELLIHELPER_H
|
||||
|
||||
#include<QPoint>
|
||||
#include<vector>
|
||||
|
||||
struct Triangle{
|
||||
QPoint A,B,C;
|
||||
};
|
||||
|
||||
namespace IntelliHelper {
|
||||
|
||||
|
||||
class IntelliHelper{
|
||||
|
||||
public:
|
||||
|
||||
static inline float sign(QPoint& p1, QPoint& p2, QPoint& p3){
|
||||
inline float sign(QPoint& p1, QPoint& p2, QPoint& p3){
|
||||
return (p1.x()-p3.x())*(p2.y()-p3.y())-(p2.x()-p3.x())*(p1.y()-p3.y());
|
||||
}
|
||||
|
||||
static inline bool isInTriangle(QPoint& A, QPoint& B, QPoint& C, QPoint& P){
|
||||
inline bool isInTriangle(QPoint& A, QPoint& B, QPoint& C, QPoint& P){
|
||||
float val1, val2, val3;
|
||||
bool neg, pos;
|
||||
|
||||
@@ -25,6 +28,11 @@ public:
|
||||
|
||||
return !(neg && pos);
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<Triangle> calculateTriangles(std::vector<QPoint> polyPoints);
|
||||
|
||||
bool isInPolygon(std::vector<Triangle> &triangles, QPoint &point);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user