28 template <
typename Real>
40 template <
typename Real>
47 std::vector<Vector2<Real>> A(numPoints);
48 for (
int i = 0; i < numPoints; ++i)
60 std::sort(A.begin(), A.end(),
63 if (P0[0] > P1[0]) {
return true; }
64 if (P0[0] < P1[0]) {
return false; }
68 auto end = std::unique(A.begin(), A.end(),
71 return P0[0] == P1[0];
74 A.erase(end, A.end());
80 std::sort(A.begin(), A.end(),
96 end = std::unique(A.begin(), A.end(),
99 return P0[1] == P1[1];
102 A.erase(end, A.end());
107 template <
typename Real>
113 int numConstraints =
static_cast<int>(A.size());
114 std::vector<bool> used(A.size());
115 std::fill(used.begin(), used.end(),
false);
125 Real axMax = (Real)0, ayMax = (Real)0;
126 for (i = 0; i < numConstraints; ++i)
144 LogAssert(iXMin != -1 && iYMin != -1,
"Unexpected condition.");
151 Real
x0 = (Real)0, xMax = ((Real)1) / axMax;
153 for (j = 0; j < numConstraints; ++j)
160 for (i = 0; i < numConstraints; ++i)
171 Real det =
DotPerp(A[iYMin], A[i]);
178 D[0] = (A[i][1] - A[iYMin][1]) / det;
179 if (x0 < D[0] && D[0] <= x1)
199 if ((Real)0.5 < A[iYMin][0] *
x0)
204 D[1] = ((Real)1 - A[iYMin][0] * D[0]) / A[iYMin][1];
209 if ((Real)0.5 < A[iYMin][0] *
x1)
215 D[0] = ((Real)0.5) / A[iYMin][0];
216 D[1] = ((Real)0.5) / A[iYMin][1];
222 LogAssert(line != -1,
"Unexpected condition.");
229 LogAssert(j < numConstraints,
"Unexpected condition.");
static void MaxProduct(std::vector< Vector2< Real >> &A, Real D[2])
#define LogAssert(condition, message)
GLfixed GLfixed GLint GLint GLfixed points
void operator()(int numPoints, Vector2< Real > const *points, Vector2< Real > const &C, Matrix2x2< Real > const &R, Real D[2]) const
Real DotPerp(Vector2< Real > const &v0, Vector2< Real > const &v1)
GLuint GLfloat GLfloat GLfloat x1