shibosoftwaredev/f1c100s-linux-nema17-stepper-controller
A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.
- Version
- 0.4.56
- License
- unset
- Stars
- 0
scripts/triangulate-review-polygon.mjs
import earcut from "earcut"
const input = JSON.parse(await new Response(Bun.stdin.stream()).text())
const flat = [], holes = []
for (const [i, ring] of [input.outer, ...input.holes].entries()) {
if (i) holes.push(flat.length / 2)
for (const [x, y] of ring.slice(0, -1)) flat.push(x, y)
}
const indices = earcut(flat, holes, 2)
const triangles = []
for (let i = 0; i < indices.length; i += 3)
triangles.push(indices.slice(i, i + 3).map(j => flat.slice(j * 2, j * 2 + 2)))
process.stdout.write(JSON.stringify(triangles))