Skip to content

Document the L-shape fitting math, add the Zhang et al. reference, fix typo - #150

Open
CloudCorpRecords wants to merge 1 commit into
ShisatoYano:mainfrom
CloudCorpRecords:docs/101-l-shape-fitting-math
Open

CloudCorpRecords wants to merge 1 commit into
ShisatoYano:mainfrom
CloudCorpRecords:docs/101-l-shape-fitting-math

Conversation

@CloudCorpRecords

Copy link
Copy Markdown

Closes #101

Overview

Docs-only change to src/components/detection/l_shape_fitting/l_shape_fitting_detector.py so a beginner can match each step of the code to an equation. No behavior change.

  • Reference: added Zhang, Xu, Dong and Dolan, "Efficient L-Shape Fitting for Vehicle Detection Using Laser Scanners", IEEE IV 2017, at the top of the file.
  • Class docstring: a 3-step overview (segment, search the direction, build the rectangle) and why a scanner sees an "L".
  • _adaptive_range_segmentation: the distance-dependent threshold r_th = MIN_RNG_TH_M + RNG_TH_RATE * d.
  • _merge_clusters: why overlapping neighborhoods are merged.
  • _rotate_points: c1 = cos(theta) x + sin(theta) y, c2 = -sin(theta) x + cos(theta) y, and why the rectangle becomes axis-aligned in that frame.
  • _calculate_variance_criterion: the distances to the nearest edge d1_i, d2_i, the split into E1/E2, gamma = -Var(E1) - Var(E2), and why the largest gamma is the best direction.
  • _calculate_rectangle: the angle search and the four edge lines a*x + b*y = c, matching the a, b, c lists passed to Rectangle.
  • Typo: _mearge_clusters -> _merge_clusters (and mearged_* locals). It was only used inside this file.
  • One clarifying comment on min_cost_angle: the criterion is maximized, so it starts at -inf. I did not rename it, to keep the change docs-only.

Testing

  • Related tests pass: pytest test/test_point_cloud_rectangle_fitting.py test/test_point_cloud_robustLS_rectangle_fitting.py test/test_rectangle.py -> 6 passed (headless, MPLBACKEND=Agg).
  • To check "no behavior change" beyond the smoke tests, I ran _calculate_rectangle and _calculate_variance_criterion on a fixed synthetic L-shaped cluster (rotated 23 degrees, seeded noise) at three angle steps before and after the edit; the printed rectangle coefficients and criterion value are identical (the fit recovers 23 degrees).
  • I did not run the whole suite (run_test_suites.sh), only the tests that import this module.

Notes, not changed here

  • The search loop is np.arange(0, pi/2 - step, step), so the last angle tried is just under pi/2 - step, not pi/2. It is harmless for a quarter-turn-symmetric rectangle, but if you want the docstring to say "[0, 90 deg)" exactly, the end bound could be pi/2. I left the behavior as is.

AI assistance

This change was made with Claude Code (an AI coding agent), as CLAUDE.md anticipates; it wrote the docstrings and ran the checks above.

…x typo

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
@CloudCorpRecords
CloudCorpRecords force-pushed the docs/101-l-shape-fitting-math branch from e465622 to c1758a1 Compare October 19, 2026 15:00
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.

Explain L-shape fitting with equations and references

1 participant