From 3c47b28c9504c19faa615d9ad53608ff59daad3b Mon Sep 17 00:00:00 2001 From: sjat Date: Thu, 11 Jun 2026 09:41:28 +0200 Subject: [PATCH] chore: remove orphaned Mat3 type; refresh README for polynomial warp --- README.md | 4 ++-- src/types.ts | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3b02fdf..b5c9f48 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,10 @@ Serve the built `dist/` as static files. Configure via `public/config.json` (bun ## Use 1. Open a local G-code file with the **Open G-code** button. -2. **Calibrate** (one-time, persisted in `config.json`): jog the CNC spindle to a known X/Y, enter those coordinates, then click the spindle tip in the video. Repeat for at least 4 well-spread points (near the table corners gives the best accuracy). Click **Compute homography** — the per-point error (px) flags any misclick. Paste the generated JSON into `public/config.json`. +2. **Calibrate** (one-time, persisted in `config.json`): jog the CNC spindle to a known X/Y, enter those coordinates, then click the spindle tip in the video. Repeat for **at least 10 well-spread points** including the table corners (distortion is worst there). A good target is a "box + #" — lines at the thirds of each axis — giving 16 points (12 on the perimeter + 4 interior crossings); jog-and-mark each so the coordinate is exact. Pick the polynomial **Degree** (default **3**, which compensates wide-angle barrel distortion; drop to 2 for sparse calibration), click **Compute warp** — the per-point error (px) flags any misclick — and paste the generated JSON into `public/config.json`. 3. **Align** the toolpath to the material: drag it to move, Shift-drag to rotate, use **Set origin by clicking video**, or type a numeric X/Y/rotation. Then reality-check the overlay against the live cut. ## Notes -- A perspective (homography) transform assumes straight cuts stay straight. If a wide-angle camera bows straight lines, the calibration per-point error will reveal it; lens-distortion correction is a possible future addition. +- Calibration uses a **bivariate polynomial warp** (machine-mm ↔ normalized image), not a plain perspective homography. A homography keeps straight lines straight, so it cannot follow the curvature a wide-angle lens introduces; the polynomial's cubic terms model that barrel distortion (which is a degree-3 effect on position), so the overlay tracks the bowed bed edges instead of drifting at the corners. The forward map draws the overlay; an independently-fit inverse map powers click-to-set-origin and dragging. - Supported G-code: G0/G1/G2/G3 motion, G90/G91, G20/G21 units, arcs via I/J or R. Cutting moves are drawn solid, rapids dashed. diff --git a/src/types.ts b/src/types.ts index 5992e39..344c818 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,8 +1,5 @@ export type Vec2 = [number, number]; -/** Row-major 3×3 matrix. */ -export type Mat3 = [number, number, number, number, number, number, number, number, number]; - /** One fitted polynomial map: dst = Σ cᵢ · monomialᵢ(normalized src). */ export interface PolyMap { degree: number;