| Algorithm 1: Pseudo-code of the swapping process between the old and new reference lines. | |
| 1: | Setting: sort the previous lines in descending order according to their length |
| 2: | For each previous line from long to short |
| 3: | If this line has matching line in the current scan and composes from number of points more than threshold |
| 4: | calculate the unit vector of this line (1st reference) |
| 5: | for each previous rest line from long to short |
| 6: | If this line has matching line in the current scan and composes from number of points more than threshold |
| 7: | calculate the unit vector of this line (2nd reference) |
| 8: | calculate the intersected angle between the two vectors |
| 9: | If angle > 90 |
| 10: | angle = 180−angle |
| 11: | End if |
| 12: | If absolute angle > threshold |
| 13: | swap the two old reference lines with the new ones |
| 14: | raise flag |
| 15: | End if |
| 16: | End if |
| 17: | End for |
| 18: | End if |
| 19: | End for |