Skip to content

Update the widths and the area in GeneralizedTrapezoid::extend_left - #148

Merged
fontanf merged 1 commit into
mainfrom
fix-trapezoid-extend-left
Oct 17, 2026
Merged

fontanf merged 1 commit into
mainfrom
fix-trapezoid-extend-left

Conversation

@fontanf

@fontanf fontanf commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Cause

extend_left moved the left side of the generalized trapezoid and updated its smallest x and its left slope, but not its widths and its area, which the constructor computes from the corners. So after extend_left, width_top, width_bottom and area returned the values of the trapezoid before it was extended: for the trapezoid (0, 2, 2, 6, 3, 5) of area 6, extend_left(0) gives an area of 11, but area() still returned 6 and width_bottom() 4 instead of 6.

Fix

extend_left recomputes width_top_, width_bottom_ and area_ like the constructor (the height doesn't change).

PackingSolver calls extend_left in src/irregular/tree_search.cpp, but only reads height() and the corners of the extended trapezoids, which were already right, so its behaviour doesn't change.

Tests

New GeneralizedTrapezoidExtendLeftTest: the extended trapezoid is compared, including all its computed attributes, with the trapezoid built directly with its left side at x = l, for a left side going right, going left, a vertical left side and a triangle. The four cases fail before the fix; the full suite passes after it (697 tests).

extend_left moved the left side of the generalized trapezoid and
updated its smallest x and its left slope, but not its widths and its
area, which the constructor computes from the corners. So after
extend_left, width_top, width_bottom and area returned the values of the
generalized trapezoid before it was extended: for a trapezoid of area 6
extended to an area of 11, area still returned 6.

extend_left now recomputes them like the constructor.
@fontanf
fontanf merged commit 9e216ba into main Oct 17, 2026
3 checks passed
@fontanf
fontanf deleted the fix-trapezoid-extend-left branch October 17, 2026 23:57
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.

1 participant