3
$\begingroup$

I have an array of "lines" each defined by 2 points. I am working with only the line segments lying between those points. I need to search lines that could continue one another (relative to some angle) and lie on the same line (with some offset)

I mean I had something like 3 lines

alt text

I solved some mathematical problem (formulation of which is my question) and got understanding that there are lines that could be called relatively one line (with some angle K and offset J)

alt text

And of course by math formulation I meant some kind of math formula like

alt text

so I know the algorithm I used such simple approach like one presented by Victor Liu https://stackoverflow.com/questions/3769885/how-to-formulate-such-problem-mathematicaly-line-continuation-search/3770275#3770275 but its Pusedo solution code and what I need is problem formulation.

My problem is its formalisation into math using some Matrix and other math words (to write into some paper=)

guys - I am a programmer - sorry=)

  • 0
    The "angle" procedure in the SO answer you linked to finds the arctangent of the line segment's slope; the "nearly parallel" routine relies on the fact that the angle between two parallel/collinear segments is an integer multiple of $\pi$.2010-09-22

1 Answers 1

2

Write one procedure that takes seg1 and seg2 as input, and returns how close their closest endpoints are. Write another procedure that computes the minimum angle between the lines containing seg1 and seg2. Finally, mix the two with some weights to determine a continuation score: how good seg2 serves as a continuation of seg1. Then select the seg2 that has the best continuation score for seg1.

(If you have, say, $10^5$ segments, then you will need to make it more efficient, which is an entirely different topic.)