Skip to content

Commit 94ca0c5

Browse files
committed
Move poly*clockwise() definition to common.cpp
1 parent 0be54f2 commit 94ca0c5

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

modules/mcc/src/common.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,30 @@ mace_center(const std::vector<cv::Point2f> &ps)
8686
return center;
8787
}
8888

89+
void polyanticlockwise(std::vector<cv::Point2f> &points)
90+
{
91+
// Sort the points in anti-clockwise order
92+
// Trace a line between the first and second point.
93+
// If the third point is at the right side, then the points are anti-clockwise
94+
cv::Point2f v1 = points[1] - points[0];
95+
cv::Point2f v2 = points[2] - points[0];
96+
97+
//if the third point is in the left side, then sort in anti-clockwise order
98+
if ((v1.x * v2.y) - (v1.y * v2.x) < 0.0)
99+
std::swap(points[1], points[3]);
100+
}
101+
void polyclockwise(std::vector<cv::Point2f> &points)
102+
{
103+
// Sort the points in clockwise order
104+
// Trace a line between the first and second point.
105+
// If the third point is at the right side, then the points are clockwise
106+
cv::Point2f v1 = points[1] - points[0];
107+
cv::Point2f v2 = points[2] - points[0];
108+
109+
//if the third point is in the left side, then sort in clockwise order
110+
if ((v1.x * v2.y) - (v1.y * v2.x) > 0.0)
111+
std::swap(points[1], points[3]);
112+
}
113+
89114
} // namespace mcc
90115
} // namespace cv

modules/mcc/src/common.hpp

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,30 +73,9 @@ void unique(const std::vector<T> &A, std::vector<T> &U)
7373
U.push_back(Tm[i]);
7474
}
7575

76-
void polyanticlockwise(std::vector<cv::Point2f> &points)
77-
{
78-
// Sort the points in anti-clockwise order
79-
// Trace a line between the first and second point.
80-
// If the third point is at the right side, then the points are anti-clockwise
81-
cv::Point2f v1 = points[1] - points[0];
82-
cv::Point2f v2 = points[2] - points[0];
83-
84-
//if the third point is in the left side, then sort in anti-clockwise order
85-
if ((v1.x * v2.y) - (v1.y * v2.x) < 0.0)
86-
std::swap(points[1], points[3]);
87-
}
88-
void polyclockwise(std::vector<cv::Point2f> &points)
89-
{
90-
// Sort the points in clockwise order
91-
// Trace a line between the first and second point.
92-
// If the third point is at the right side, then the points are clockwise
93-
cv::Point2f v1 = points[1] - points[0];
94-
cv::Point2f v2 = points[2] - points[0];
95-
96-
//if the third point is in the left side, then sort in clockwise order
97-
if ((v1.x * v2.y) - (v1.y * v2.x) > 0.0)
98-
std::swap(points[1], points[3]);
99-
}
76+
void polyanticlockwise(std::vector<cv::Point2f> &points);
77+
void polyclockwise(std::vector<cv::Point2f> &points);
78+
10079
// Does lexical cast of the input argument to string
10180
template <typename T>
10281
std::string ToString(const T &value)

0 commit comments

Comments
 (0)