Walls And Holes  1
geometry.h
Go to the documentation of this file.
1 #ifndef GEOMETRY_H
2 #define GEOMETRY_H
3 
4 #include <QPointF>
5 #include <QVector3D>
6 #include <QtMath>
7 
8 namespace Geometry {
9 
10 //0 - a, b, and c are colinear
11 //1 - Clockwise
12 //2 - Counter Clockwise
13 inline int orientation(QPointF a, QPointF b, QPointF c)
14 {
15  QVector3D A(b.x() - a.x(), 0, b.y() - a.y());
16  QVector3D B(c.x() - a.x(), 0, c.y() - a.y());
17 
18  QVector3D AxB = QVector3D::crossProduct(A, B);
19 
20  if (qAbs(AxB.y()) <= 0.01) return 0;
21  if (AxB.y() > 0) return 2;
22  else return 1;
23 }
24 
25 }
26 
27 #endif // GEOMETRY_H
Definition: geometry.h:8
int orientation(QPointF a, QPointF b, QPointF c)
Definition: geometry.h:13