Home > Software design >  The algorithm for the alignment of arrows
The algorithm for the alignment of arrows

Time:08-19

I have blocks that are anchored to a place by coordinates (X, Y). And there are also arrows that are now being built in a straight line from block A to block B, crossing other blocks.

In turn, I added an intermediate point C (X1, Y2) between A(x1, y1) and B(x2, y2), so that the arrow is built orthogonally, but it still intersects other blocks and arrows.

Are there any existing algorithms to give the arrows an orthogonal look, without intersecting other blocks, and overlapping arrows on top of each other (except for intersections at a point)?

The program makes it possible to work with a flowchart written in c# winforms.

Thanks for the answers.

CodePudding user response:

Except for trivial cases, it is impossible to prevent arrows overlapping in a 2D diagram. This is handled by drawing one of the overlapping arrows with a small semi-circle, indicating that the arrow "hops" over the other.

To avoid blocks, think of each arrow finding a path from block A to B through an orthogonal grid containing obstacles ( the other blocks ). The A* search algorithm will do this ( https://en.wikipedia.org/wiki/A*_search_algorithm ).

  • Related