I am creating a web service that aims to mimic how electronic circuits work. the project is not yet at the Alpha stage.
I was stuck in some important milestone of the project: when someone tries to connect one component pin to another pin, a communication line should be built.
First of all, the connection line was simply straight, without any changes.

Then it became some kind of bend of the line with the ability to add, move and delete points that determined how the line bends.

And now it (the connection line) is created using the A * algorithm.

The implementation is still not very good, so editing a line with the A * extension is not a good idea, because it fails.
The idea for an algorithm for creating a connection line is as follows:
define start and end points
find a path between the beginning and the end that does not overlap the bounding box of an existing component
create a set of base points - a list of coordinates obtained from step # 2 + beginning from the top of the heap + on the tail
create a set of lines that form a join line:
for (var i = 1; i < points.length; i++) { var p0 = points[i - 1], p1 = points[i], line = MooChip.paper.path(Raphael.format('M%1,%2L%3,%4', p0.x, p0.y, p1.x, p1.y)); }
The problem is that the communication lines can overlap, and they should only intersect ... Well, in fact there is one more problem: I did not even imagine how to connect the connection lines, for example, the lower left image:

Question: how should I build a connection path (so that it is mostly close to a well-designed circuit, say) and how can I implement schematic connections?
shybovycha
source share