In our system, there're the requirements that we want to move some source lines (with low precision) to reference lines (with high precision). Following pictures gives the normal use cases. The red one is a source line and the blue one is a reference line.
For this case, the source line would be moved partially, and the result would be as the green line shows:
There're situations that the source line need to be moved completely.
Result:
Currently our solution is to project head/end point of the source line to the reference line and vice versa, then find projected points on the source and reference line. With these projected points, we can extract the needed part of the source and reference line and then combine them into a new one.
This works for most cases, but there are cases that this method does not work. Specifically, when either of the line has "C" like shape or the head point is very close to the end point. The next two pictures gives the scenario.
Applying my algorithm, we get the result:
In a way it's understandable because the current algorithm just finds projected points and extracts lines.
What we expected is something like this:
So what I need more robust algorithm to do this so that it can also handle special cases like the preceding one. I have tried to project every points from a line to another and to find the two projected points that closest to the head/end point of the projected line, but there was no luck. Still I can find cases that give unexpected results.
Has anyone come across similar problems before? It would be also great if there is a software or library can do similar job. Any answer will be appreciated.
No comments:
Post a Comment