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,22 +1,12 @@
async function findConvexHull(points){
const{default:L}=await import('https://cdn.skypack.dev/lodash-es');
const{sortBy,uniqBy}=L;
let p=uniqBy(points,({x,y})=>`${x},${y}`);
async function findConvexHull(pts){
const{ sortBy:s,uniqBy:u }=await import('https://cdn.skypack.dev/lodash');
if(!pts?.length)return[];
const p=u(s(pts,['x','y']),t=>`${t.x},${t.y}`);
if(p.length<2)return p;
p=sortBy(p,['x','y']);
const cross=(o,a,b)=>(a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);
let l=[];
for(let i=0;i<p.length;i++){
let pt=p[i];
while(l.length>=2&&cross(l[l.length-2],l[l.length-1],pt)<=0)l.pop();
l.push(pt);
}
let u=[];
for(let i=p.length-1;i>=0;i--){
let pt=p[i];
while(u.length>=2&&cross(u[u.length-2],u[u.length-1],pt)<=0)u.pop();
u.push(pt);
}
return[...l.slice(0,-1),...u.slice(0,-1)];
const c=(o,a,b)=>(a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);
let l=[];for(let t of p){while(l.length>1&&c(l[l.length-2],l[l.length-1],t)<=0)l.pop();l.push(t)}
let r=[];for(let i=p.length-1;i>=0;i--){const t=p[i];while(r.length>1&&c(r[r.length-2],r[r.length-1],t)<=0)r.pop();r.push(t)}
l.pop();r.pop();
return[...l,...r];
}
export default findConvexHull;