Ocular Engine
ConvexHull2D.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_MATH_CONVEX_HULL_2D__H__
19 #define __H__OCULAR_MATH_CONVEX_HULL_2D__H__
20 
21 #include "Math/Vector2.hpp"
22 #include "Math/Geometry/LineSegment2D.hpp"
23 #include <vector>
24 
25 //------------------------------------------------------------------------------------------
26 
31 namespace Ocular
32 {
37  namespace Math
38  {
51  {
52  public:
53 
57  ConvexHull2D(std::vector<Point2f> const& points);
58 
63  ConvexHull2D(Point2f const*, uint32_t numPoints);
64 
65  ~ConvexHull2D();
66 
70  void sort();
71 
75  uint32_t getNumPoints() const;
76 
81  std::vector<Point2f> const& getHull() const;
82 
83  protected:
84 
85  void createHull();
86  void splitCollection(LineSegment2Df const& segment, std::vector<Point2f>& leftGroup, std::vector<Point2f>& rightGroup);
87  void findHull(LineSegment2Df const& segment, std::vector<Point2f>& points);
88 
89  private:
90 
91  std::vector<Point2f> m_Points;
92  std::vector<Point2f> m_Hull;
93 
94  Point2f m_DistantA; // The two most distant points. Used for sorting.
95  Point2f m_DistantB;
96  };
97  }
101 }
106 //------------------------------------------------------------------------------------------
107 
108 #endif
ConvexHull2D(std::vector< Point2f > const &points)
Definition: ConvexHull2D.cpp:36
Definition: LineSegment2D.hpp:52
void sort()
Definition: ConvexHull2D.cpp:70
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Definition: Vector2.hpp:44
Definition: ConvexHull2D.hpp:50
std::vector< Point2f > const & getHull() const
Definition: ConvexHull2D.cpp:80
void findHull(LineSegment2Df const &segment, std::vector< Point2f > &points)
Definition: ConvexHull2D.cpp:196
uint32_t getNumPoints() const
Definition: ConvexHull2D.cpp:75