tikzdraw.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:freehand-zxcalculus-recognition 作者: emmacaort 项目源码 文件源码
def get_ref_centre(nodelist):
    """Choose a node as the diagram centre and find the unit distance.

    Find the shortest distance between two nodes and use it as the unit distance of the 
    diagram grid. Choose one of these two nodes as the diagram centre.

    Args:
        nodelist (list): A list of nodes

    Returns:
        The absolute position of the centre node and the unit distance of the diagram.
    """    
    centres = [node.centre for node in nodelist]
    min_d = sp.dist(centres[0], centres[1])    
    min_p0,min_p1 = centres[0], centres[1]
    for p0, p1 in itertools.combinations(centres, 2):
        d = sp.dist(p0,p1)
        if d < min_d:
            min_d = d
            min_p0,min_p1 = p0,p1   
    min_x = abs(min_p0[0] - min_p1[0])
    min_y = abs(min_p0[1] - min_p1[1])
    unit_d = max(min_x, min_y)
    return [min_p0,unit_d]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号