Docs: Update benchmark results

This commit is contained in:
github-actions[bot]
2025-11-18 23:31:52 +00:00
parent 341252fec1
commit 5855cf8a6f
77 changed files with 972 additions and 1051 deletions

View File

@@ -1,27 +1,28 @@
const findConvexHull = async (points) => {
const _ = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js');
async const findConvexHull = async (points) => {
const { sortBy, uniqWith, isEqual } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js');
const uniquePts = _.uniqWith(points, _.isEqual);
if (uniquePts.length < 3) {
return uniquePts;
const cross = (p1, p2, p3) =>
(p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x);
const sortedPoints = sortBy(uniqWith(points, isEqual), ['x', 'y']);
if (sortedPoints.length <= 3) {
return sortedPoints;
}
const crossProduct = (o, a, b) =>
(a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const sortedPts = _.sortBy(uniquePts, ['x', 'y']);
const buildHalfHull = (pts) =>
pts.reduce((hull, p) => {
while (hull.length >= 2 && crossProduct(hull.at(-2), hull.at(-1), p) <= 0) {
const buildHull = (pointSet) => {
const hull = [];
for (const p of pointSet) {
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
hull.pop();
}
hull.push(p);
return hull;
}, []);
}
return hull;
};
const lower = buildHalfHull(sortedPts);
const upper = buildHalfHull([...sortedPts].reverse());
const lower = buildHull(sortedPoints);
const upper = buildHull([...sortedPoints].reverse());
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
};