Electronic cIrcuit diagram component connection algorithm [closed]

╄→尐↘猪︶ㄣ 提交于 2019-12-21 10:46:33

问题


I am creating a web-service which is aimed to simulate how do electronic circuits work. The project is not even in the Alpha stage yet.

I am stuck with some important milestone of the project: when one tries to connect one component's pin to some other pin - the connection line should be built.

First of all, the connection line was just a straight line, without almost any way to change it.

Then it became somehow bended line with the possibility to add, move and delete points, which determined how the line is bended.

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

The implementation is not well yet, so editing A*-generated connection line is not a good idea, 'cause it fails a lot.

The idea for the connection line creation algorithm is just as follows:

  1. determine start and end points

  2. find a path between start and end, which does not overlap any existing component' bounding box

  3. create a set of base points - a list of coordinates, got from the step #2 + start at the heap + end at the tail

  4. create a set of lines which will form a connection 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 connection lines could overlap, while they must intersect only... Well, actually there is another problem: i could not even imagine how one could implement connection lines connection, like here, the bottom-left image:

The question is: how should i build the connection path (to make it mostly close to the well-designed circuit diagram, let's say) and how can i implement schematic junctions?


回答1:


Firstly, at this moment i can't give whole solutions, but maybe it will help:

  • check graphflow project, its javascript canvas view builds the graph and aligns it based on connections as i see. That is exactly what is needed for circuits (f.e. GND sign will be vertex with only one connection, so will be drawn at the boundary region of schema)
  • that approach should be modified somehow with putting it to grid and making all connections orthogonal
  • about "connection path" it is just one more element and should be aligned as others. It is like transistor, but too small to see all three connectors


来源:https://stackoverflow.com/questions/10296758/electronic-circuit-diagram-component-connection-algorithm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!