mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-13 16:17:54 +00:00
Docs: Update benchmark for openrouter/sherlock-dash-alpha
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
async function findConvexHull(points) {
|
||||
const {_, default: _} = await import('https://cdn.skypack.dev/lodash-es');
|
||||
const pts = _([...new Set(points.map(p=>`${p.x},${p.y}`))].map(s=>s.split(',').map(Number)).map(([x,y])=>({x,y})));
|
||||
const ccw=(a,b,c)=> (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
|
||||
const build=(pts,low)=> {
|
||||
const hull=[];
|
||||
for(let p of pts){
|
||||
while(hull.length>1&&ccw(hull[hull.length-2],hull[hull.length-1],p)<=0) hull.pop();
|
||||
hull.push(p);
|
||||
}
|
||||
return hull.slice(0,low?hull.length:hull.length-1);
|
||||
};
|
||||
if(pts.length<3) return pts;
|
||||
return [...build(pts.sort((a,b)=>a.x-b.x||a.y-b.y),1),...build(pts.slice().reverse(),0)];
|
||||
}
|
||||
export default findConvexHull;
|
||||
Reference in New Issue
Block a user