Public
Edited
Mar 27, 2021
1 fork
Importers
39 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
orient = (rx, ry, qx, qy, px, py) => (px - rx) * (qy - ry) - (py - ry) * (qx - rx)
Insert cell
Insert cell
orientSymmetrical = (rx, ry, qx, qy, px, py) =>
(px * qy - py * qx) + (qx * ry - qy * rx) + (rx * py - ry * px)
Insert cell
Insert cell
orientSymmetrical2 = (rx, ry, qx, qy, px, py) =>
(px * qy + qx * ry + rx * py) - (py * qx + qy * rx + ry * px)
Insert cell
Insert cell
orientBetter = {
function orient(px, py, rx, ry, qx, qy) {
const l = (ry - py) * (qx - px);
const r = (rx - px) * (qy - py);
return Math.abs(l - r) >= 3.3306690738754716e-16 * Math.abs(l + r) ? l - r : 0;
}
return (rx, ry, qx, qy, px, py) =>
orient(px, py, rx, ry, qx, qy) ||
orient(rx, ry, qx, qy, px, py) ||
orient(qx, qy, px, py, rx, ry);
}
Insert cell
Insert cell
orientRobust = (await import('https://cdn.skypack.dev/robust-predicates@3.0.0')).orient2d
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more