def set_cartesian_coordinate(self, x, y):
        """
        Set cartesian coordinate
        """
        cartesian = CartesianCoordinate(x, y)
        r, t = cartesian.to_polar()

        self.set_polar_coordinate(r, math.degrees(t))
Exemplo n.º 2
0
def sort_children(children, father):
    """
    """
    if len(children) < 2:
        return children

    # create angle reference
    f_x, f_y = father.get_cartesian_coordinate()

    for child in children:

        c_x, c_y = child.get_cartesian_coordinate()
        _, angle = CartesianCoordinate(c_x - f_x, c_y - f_y).to_polar()

        child.set_draw_info({'angle_from_father': math.degrees(angle)})

    return sort_children_by_angle(children)