Geometric.LinesegmentUtils

Geometric.LinesegmentUtils#

Geometric.LinesegmentUtils.py

linregress_segments(segments)#

Perform linear regression on the center points of the given line segments.

Parameters:

segments (list of Linesegment) – The list of line segments to perform regression on.

Returns:

  • slope (float) – The slope of the fitted line.

  • intercept (float) – The intercept of the fitted line.

reduce_segments(segments, i)#

Reduce two adjacent line segments into one by merging them.

Parameters:
  • segments (list of Linesegment) – The list of line segments.

  • i (int) – The index of the first segment to merge with the next one.

Returns:

The function modifies the segments list in place.

Return type:

None

restore_segments(slope, intercept, segments)#

Restore the original y-values of the line segments by reversing the linear transformation.

Parameters:
  • slope (float) – The slope of the linear transformation applied to the y-values.

  • intercept (float) – The intercept of the linear transformation applied to the y-values.

  • segments (list of Linesegment) – The list of line segments to restore.

Returns:

The list of restored line segments.

Return type:

list of Linesegment