project static method
Get max and min dot product of a convex hull at position (pos,quat) projected onto an axis.
Results are saved in the array maxmin.
@param result result0
and result1
will be set to maximum and minimum, respectively.
Implementation
static void project(ConvexPolyhedron shape, Vec3 axis, Vec3 pos, Quaternion quat, final List<double> result) {
final int n = shape.vertices.length;
//final worldVertex = project_worldVertex;
final localAxis = _projectLocalAxis;
double max = 0;
double min = 0;
final localOrigin = _projectLocalOrigin;
final vs = shape.vertices;
localOrigin.setZero();
// Transform the axis to local
Transform.vectorToLocalFrame(pos, quat, axis, localAxis);
Transform.pointToLocalFrame(pos, quat, localOrigin, localOrigin);
final add = localOrigin.dot(localAxis);
min = max = vs[0].dot(localAxis);
for (int i = 1; i < n; i++) {
final val = vs[i].dot(localAxis);
if (val > max) {
max = val;
}
if (val < min) {
min = val;
}
}
min -= add;
max -= add;
if (min > max) {
// Inconsistent - swap
final temp = min;
min = max;
max = temp;
}
// Output
result[0] = max;
result[1] = min;
}