Skip to content

LinearModelSolver: fix the normal of the 2-point line (fixes #58) - #59

Open
f-dy wants to merge 2 commits into
danini:masterfrom
f-dy:fix/line-normal
Open

f-dy wants to merge 2 commits into
danini:masterfrom
f-dy:fix/line-normal

Conversation

@f-dy

@f-dy f-dy commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #58. LinearModelSolver<2>::estimate2DLine computed the normal of the line through its two sampled points as (y1 − x2, x2 − x1) instead of (y1 − y2, x2 − x1), so every 2-point line hypothesis was wrong unless x2 = y2 or x1 = x2. This PR changes x2 to y2 (line 175).

Testing: a new test, tests/test_line2d.py: 20 calls of findLine2D, with 10 iterations each, on 50 noise-free points of y = 2x + 1 must each return that line with every point as an inlier. It fails in 20 of 20 runs on master (a single call passes about one time in three, since the sampler is random and the local optimization sometimes repairs the line) and passes in 40 of 40 with the fix; the other tests pass (macOS, Apple clang). Independent of #52 (the null-sample crash in the same file): the two merge cleanly in either order.

Updates after review: the test makes 20 calls instead of one, so that it fails on master every time (a single call passed on master in about a third of the runs).

estimate2DLine computed nx = y1 - x2 instead of y1 - y2, so the line through two
sampled points was wrong unless x2 == y2. Adds a test: 10 iterations on noise-free
points of a line find every point.
A single call passed without the fix in about a third of the runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The 2-point line fit computes the wrong normal (y1 - x2 instead of y1 - y2)

1 participant