mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-19 18:24:50 +00:00
Docs: Update Gemini benchmark results
This commit is contained in:
@@ -1,16 +1,24 @@
|
||||
const findConvexHull = async (pts) => {
|
||||
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
|
||||
const u = _.uniqWith(pts, _.isEqual)
|
||||
if (u.length < 3) return u
|
||||
const s = _.sortBy(u, ['x', 'y'])
|
||||
const cp = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
|
||||
const scan = (lst) => lst.reduce((h, p) => {
|
||||
while (h.length >= 2 && cp(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
|
||||
h.push(p)
|
||||
return h
|
||||
}, [])
|
||||
const l = scan(s)
|
||||
const up = scan([...s].reverse())
|
||||
return [...l.slice(0, -1), ...up.slice(0, -1)]
|
||||
}
|
||||
const findConvexHull = async (p) => {
|
||||
const { default: _ } = await import('https://cdn.skypack.dev/lodash');
|
||||
const s = _.sortBy(_.uniqWith(p, _.isEqual), ['x', 'y']);
|
||||
if (s.length < 3) return s;
|
||||
|
||||
const x = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
||||
const h = [];
|
||||
|
||||
for (const i of s) {
|
||||
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], i) <= 0) h.pop();
|
||||
h.push(i);
|
||||
}
|
||||
|
||||
const t = h.length + 1;
|
||||
for (let i = s.length - 2; i >= 0; i--) {
|
||||
const k = s[i];
|
||||
while (h.length >= t && x(h[h.length - 2], h[h.length - 1], k) <= 0) h.pop();
|
||||
h.push(k);
|
||||
}
|
||||
|
||||
h.pop();
|
||||
return h;
|
||||
};
|
||||
export default findConvexHull;
|
||||
Reference in New Issue
Block a user