Algorithm for connecting electronic components

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.

enter image description here

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.

enter image description here

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

enter image description here

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:

enter image description here

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?

+7
source share
1 answer

Firstly, at the moment I can not give whole solutions, but maybe this will help:

  • check the graphflow project, viewing it in javascript creates a graph and aligns it based on the connections, as I see. This is exactly what is needed for circuits (for example, the GND sign will be a vertex with one connection, so it will be drawn in the boundary region of the circuit)
  • this approach needs to be modified in some way, placing it in a grid and making all connections orthogonal
  • About the "connection path" is just one more element and should be aligned like the others. It looks like a transistor, but too small to see all three connectors
+1
source

All Articles