55 return ((p1.
x - p2.
x) * (p3.
y - p2.
y)) - ((p3.
x - p2.
x) * (p1.
y - p2.
y));
63 const int nPoints = input.
GetSize();
65 for (
int i = 0; i < nPoints; i++)
71 const int nLastIndex = output.
GetSize() - 1;
73 if (
det(output[nLastIndex - 2], output[nLastIndex - 1], output[nLastIndex]) <= 0.0f)
86 const int nPoints = input.
GetSize();
88 for (
int i = nPoints - 1; i >= 0; i--)
94 const int nLastIndex = output.
GetSize() - 1;
96 if (
det(output[nLastIndex - 2], output[nLastIndex - 1], output[nLastIndex]) <= 0.0f)
109 const float fX = pPoints[(nLow + nHigh) / 2].
x;
113 while (pPoints[i].
x < fX) i++;
114 while (pPoints[j].
x > fX) j--;
138 for (i = 0; i < nPoints; i++)
143 const int nLastPoint = vertices.
GetSize() - 1;
144 const Vec2d &left = vertices[0];
145 const Vec2d &right = vertices[nLastPoint];
149 CVec2dArray upper(2 * nPoints), lower(2 * nPoints);
150 upper.AddElement(left);
151 for (i = 1; i < nLastPoint; i++)
153 const Vec2d &point = vertices[i];
155 if (
det(left, point, right) < 0.0f)
179 const int nHullSize = hull.
GetSize() - 1;
180 for (i = 0; i < nHullSize; i++)
static void BuildLowerHalfHull(const CVec2dArray &input, CVec2dArray &output)
static void BuildUpperHalfHull(const CVec2dArray &input, CVec2dArray &output)
static void QuicksortX(CVec2dArray &pPoints, int nLow, int nHigh)
GLenum GLenum GLenum input
void AddElement(const T &element)
Data structure for the representation of a 2D vector.
void SetVec(Vec2d &vec, float x, float y)
static float det(const Vec2d &p1, const Vec2d &p2, const Vec2d &p3)
bool DeleteElement(int nIndex)
void ComputeConvexHull(const Vec2d *pPoints, int nPoints, Vec2d *pResultPoints, int &nResultPoints)
Computes the convex hull for a set of contour points.