From 272a761892683ca7834e1ca5a0c4eb9f2f2e3ac6 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 05:24:51 +0100 Subject: [PATCH] docs/reference.md: fit_shell's reading of a trace and what it does not separate, depth across the run and the 0.2 line, free cages, and that a spine is decided by its plane Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/docs/reference.md | 110 ++++++++++++++++++----------- 1 file changed, 67 insertions(+), 43 deletions(-) diff --git a/surfaces/blender/docs/reference.md b/surfaces/blender/docs/reference.md index 3617042..31cfb89 100644 --- a/surfaces/blender/docs/reference.md +++ b/surfaces/blender/docs/reference.md @@ -176,7 +176,7 @@ because the operator base pushes an undo step). A kitbash shell (`kitbash.md`, "Making a shell") is blocked in by eye; `fit_shell` moves the cage points of its traced runs until the runs, as Blender builds them and the cameras draw them, lie on the traces. A run is a hard -crease or rim run of a loft, named as the sheet's creases name runs. The unknowns are the authored points on the +crease or rim run of a loft or of a free cage, named as the sheet's creases name runs. The unknowns are the authored points on the traced runs; a mirrored sheet is one set of points seen twice, so a trace of each half through one camera is two views of the run (Francois et al. 2003), and that is where depth comes from in a single picture. Each built point of a run is pulled onto its trace along the trace's normal, and the run's two ends onto the trace's ends; no @@ -185,69 +185,93 @@ Cipolla's edge tracker). A prior holds every point to the sheet as it stands: a diagonal costs what one pixel of miss does. ```json -{"action": "brokkr_reference.fit_shell", "object_name": "Pauldron", "tol": 3, +{"action": "brokkr_reference.fit_shell", "object_name": "Pauldron", "traces": "[{\"camera\": \"Concept\", \"box\": [0, 0, 1024, 1024], \"run\": {\"column\": 3, \"from\": 0, \"to\": 5}, \"side\": 1, \"line\": [[412.5, 96.0], [431.0, 180.2], [440.8, 266.0]]}, {\"camera\": \"Concept\", \"box\": [0, 0, 1024, 1024], \"run\": {\"column\": 3, \"from\": 0, \"to\": 5}, \"side\": -1, \"line\": [[612.0, 90.5], [590.2, 176.0], [583.1, 262.4]]}]"} ``` | field | | | --- | --- | -| `object_name` | a loft shell made by `brokkr_kitbash.shell`, unscaled; its place in the world is the sheet's frame | +| `object_name` | a shell made by `brokkr_kitbash.shell`, unscaled; its place in the world is the sheet's frame | | `traces` | a JSON array, up to 12000 characters, of `{camera, box, run, side, line}` | | `share` | the prior (default 0.1) | -| `tol` | pixels (default 3): every point of every trace must lie this near its built run | +| `tol` | pixels (default 5): nine tenths of every trace, 5% of it left out at each end, must lie this near its built run | In a trace, `camera` names a camera object (`solve_camera` stands one) and `box` is its frame on the image, absent -for the render's own; `run` is `{"ring": i, "from": a, "to": b}` or `{"column": j, "from": a, "to": b}` in authored -indices; `side` is 1, or -1 for the mirrored half of a mirrored sheet; `line` is `[[u, v], ...]` in the box's -pixels, drawn from the run's `from` end to its `to` end. +for the render's own; `run` is `{"ring": i, "from": a, "to": b}` or `{"column": j, "from": a, "to": b}` on a loft and +`{"verts": [v, ...]}`, the run's vertices in order, on a free cage, all in authored indices; `side` is 1, or -1 +for the mirrored half of a mirrored sheet (the reflections `brokkr_kitbash`'s parser makes: `Sheet.mirror_of`); +`line` is `[[u, v], ...]` in the box's pixels, drawn from the run's first point to its last. **It returns a fit only where the built runs explain every trace.** After the fit, each trace is walked a pixel -at a time, and every point of it must lie within `tol` of its run as built and drawn. Otherwise the action is -refused, naming the trace, how much of it is unexplained, where along it and by how much, and nothing is returned -as a fit. The fit's own residual is no such test: on strokes doubled back over part of themselves 3% of the view -off, every fit converged and without this check all of them came back, up to 0.10 m wrong on a 2 m crease; with -it every one is refused (the least reads 9 px against the 3 asked). The check also binds the ends: a trace that -runs on past where its run ends, or two traces of a mirrored pair whose tips are not one point and its mirror -image through the camera, are refused at the tip. +at a time and each point's distance from its run, as built and drawn, is taken. The trace's reading, +`unexplained_px`, is the 90th percentile of those distances with 5% of the trace left out at each end; over `tol` +the action is refused, naming the trace, its reading, how much of it lies past `tol` and where, and nothing is +returned as a fit. `worst_px` is the furthest any point of the whole trace stands, ends included. The fit's own +residual is no such test: on strokes doubled back over part of themselves 3% of the view off, every fit converged +and without this check all of them came back, up to 0.10 m wrong on a 2 m crease. + +The ends are left out and the reading is not the worst point because a hand trace's tip is where two traces +cannot agree: the Orchid's hand-traced pair reads 0.69 px, with one tip 9.2 px off its run, and that pair's least +1% overdraw has a worst point of 9.1 px. The percentile, the 5% and the default were read from 296 fits and set +by the margin rule (`tests/test_reference.py`, `FitTests`): what should pass reads 3.26 px at most (hand traces +wandering 1 and 2 px), what should not reads 7.65 and up (the Orchid's traces overdrawn 2% of their extent, +synthetic strokes 3% off), and 5 sits 1.53 from each. + +**A very unsteady hand and a slight overdraw are not told apart.** Hand traces wandering 4 px read up to 5.96 +(31 of 36 pass the default); strokes overdrawn 1% read from 2.63 (12 of 45 pass) and 2% from 5.34 (none pass, with +no margin). The reading orders 99.8% of hand trace against 2 to 3% overdraw pairs rightly, but no threshold +stands 1.2 from both the 4 px hand traces and the 2% overdraws. So the reading is in the report of every accepted fit and in every refusal: near 5, look at the trace. An accepted trace +reading 3 to 5 px may be a 1% overdraw; a refused one reading 5 to 6 may be a clean stroke from an unsteady hand, +and asking again with `tol` over its reading is the caller's judgement. A doubled stretch shorter than a tenth of +the trace, or one inside the 5% at an end, does not move the reading: `worst_px` shows it. **It writes nothing.** The report carries `sheet`, the shell's own request with the traced points moved, ready for `brokkr_kitbash.shell`, which is the cage's one writer; `flow_score` on the rebuilt shell is the score. The -rest of the report: `traces` (`[{miss_px, unexplained_px}]`: the root mean square distance of the built points -from the trace, and the trace's furthest point from the built run), `points` (`[{ring, point, moved_m, m_per_px, -prior_share}]`, one per moved point) and `seconds`. +rest of the report: `traces` (`[{unexplained_px, worst_px}]`), `points` (`[{ring, point, moved_m, m_per_px, +prior_share}]` on a loft, `[{vertex, ...}]` on a free cage, one per moved point) and `seconds`. -`m_per_px` says how far a point slides along its line of sight per pixel of error in the traces (the worst of -the views that trace it), from the inverse of the fit's normal matrix, prior included (Triggs et al. 2000, -sections 9 and 10). `prior_share` is that over `share` x the diagonal: at 1 the traces say nothing about the -point along the sight line and it stands where the blocking put it. Read it per point: +`m_per_px` says how far a point slides in depth across its run per pixel of error in the traces: along the part +of its line of sight that stands across the run there (the worst of the traces that draw it), from the inverse +of the fit's normal matrix, prior included (Triggs et al. 2000, sections 9 and 10). A point's slide along its own +run is left out: the traces do not decide it and it does not move the built run. `prior_share` is `m_per_px` over +`share` x the diagonal: near 1 the traces say nothing about the point's depth and it stands where the blocking +put it. Read it per point against 0.2: -- A run traced on one half only, in one view, reads 1.0 on every point: its depth is the blocking's. -- A mirrored pair reads low where the mirror plane stands well off the sight line. On the Orchid's concept c09 - (plane 34 degrees off, a nearly orthographic camera) the pair's points read 0.12 at most, 0.024 m per px on a - ship one unit long. -- The sight line is taken whole. Where a run recedes along the view, a cage point's slide along its own run is - in the reading: the traces do not decide that slide and it does not move the built run. A column 24 to 38 - degrees off the sight line, both halves traced and its built run right to 0.2 mm, reads 0.63 to 0.88 on its - inner points. A high reading on such a run is not a depth error. -- A run on the mirror plane itself (a spine, a keel) has no partner and reads 1.0. +- **Under 0.2 the traces decide the point.** A mirrored pair traced in one view: over 18 fits every point reads + 0.080 or under and the built run is right to 0.7 mm. The Orchid's concept c09 pair reads 0.018 at most. +- **Over 0.2 the blocking holds it.** One half traced in one view: over the same 18 fits every inner point reads + 0.50 to 1.0 (the sine of the angle its run stands off the line of sight) and the built run is 18 to 355 mm + wrong. Either Orchid trace alone reads 0.27 and up on every point. 0.2 is the geometric mean of 0.080 and + 0.50, 2.5 from each. +- A run's end seen along the run reads low even on a single trace (down to 0.005): there the line of sight is + the run's own direction, and the depth across the run is decided. +- A run on the mirror plane (a spine, a keel) has no partner and needs none: its points stay on the plane, which + decides their depth. A spine traced once read 0.019 at most and came back within 0.15 mm. + +`m_per_px` is what one pixel of error on one point moves, not a bound on the fit's error. Clean strokes came back +within 0.16 of `tol` x the worst `m_per_px` they report. Hand traces whose wander holds over 30 px did not: of 24 +fitted (wander 2 and 4 px), 13 ended further off than that, up to 2.5 times (20 to 87 mm on a 2 m crease), while +every point read a `prior_share` under 0.05. A low reading says the traces decide the point; how well they decide it +is as good as the traces are. What it refuses before fitting, naming the trace: a run with an edge under weight 1 (a semi-sharp edge rounds off by an amount the fit does not model), a run whose end does not hold (a dart; a ring run from point 0 of a mirrored sheet, which runs on across the middle), a run with a point held partway (a corner point or a crossing -crease: trace it as two), a closed loop, an unknown camera, a line of fewer than two points, a free cage (it has -no rings or columns; `core.fit_runs` takes vertex chains), a scaled shell, and a result that would pass the -16000 characters a receipt carries. +crease: trace it as two), a closed loop, an unknown camera, a line of fewer than two points, a run named in the +other form's words (`verts` on a loft, a ring or column on a free cage), a scaled shell, and a result that would +pass the 16000 characters a receipt carries. Measured (Blender 5.3 and Python 3.13 on Starfire): a mirrored column of 10 points traced in one view at a time, from blockings 0.10 m and 0.30 m off a 2 m crease, came back within 0.7 mm in 0.1 to 0.6 s. The Orchid's c09 -petal edges, traced by hand through a camera solved from hand marks (13 px rms), are refused at 3 px: the left -trace's first 10 px stand up to 9.2 px off the built run. At 18.5 px they fit in 0.2 s, and from blockings 5%, -10% and 20% of the ship's length off the built run lands in one place, 2.0% of the length from a stand-in mesh -in the mean and 3.4% at worst. A trace drawn by hand through a camera solved by hand wants a `tol` near that -camera's own `rms`, and the acceptance is then that much weaker. +petal edges, traced by hand through a camera solved from hand marks (13 px rms), are accepted at the default, +reading 0.69 and 0.64 px, in 0.2 s; from blockings 5%, 10% and 20% of the ship's length off the built run lands +in one place, 2.0% of the length from a stand-in mesh in the mean and 3.4% at worst. A mirrored free cage's +crease of six vertices, blocked 0.056 m off, came back within 0.43 mm through the action in 0.02 s. -What it gives up: it fits hard runs of a loft only. Silhouettes of the smooth surface, semi-sharp creases and -free cages are not fitted; a run's depth with no mirror partner and no second view is the blocking's. +What it gives up: it fits hard runs only. Silhouettes of the smooth surface and semi-sharp creases are not +fitted; a run's depth with no mirror partner, no second view and no mirror plane under it is the blocking's. +The acceptance reads nine tenths of a trace: it passes a short doubled stretch and a tip that stands off, and +reports both as `worst_px`. ## What it cannot do @@ -274,6 +298,6 @@ cam2 = core.camera_of(params, box) # and back The tests are `tests/test_reference.py` (no Blender), `tests/live/reference.py` (a known scene rendered, solved through the action and rendered again; `reference.result.json` is its last run) and `tests/live/reference_flow.py` (`crease_run` against Blender's own subdivision, a box and a folded sheet scored by `flow_score`; -`reference_flow.result.json` is its last run) and `tests/live/reference_fit.py` (a mirrored shell blocked off its -design, fitted through the action, rebuilt by `brokkr_kitbash.shell` and scored; `reference_fit.result.json` is -its last run). +`reference_flow.result.json` is its last run) and `tests/live/reference_fit.py` (a mirrored loft and a mirrored +free cage, each blocked off its design, fitted through the action and rebuilt by `brokkr_kitbash.shell`; +`reference_fit.result.json` is its last run).