예제 #1
0
def drawPerpendicularBisector(pt1, pt2, beginning, finish):
    centerX = (pt1.x + pt2.x) / 2
    centerY = (pt1.y + pt2.y) / 2
    start = Point(0, 0)
    end = Point(0, 0)
    if pt1.y - pt2.y != 0:
        start.x = beginning.x
        start.y = centerY + (centerX - beginning.x)*((pt1.x-pt2.x)/(pt1.y-pt2.y))
        end.x = finish.x
        end.y = centerY - (finish.x - centerX)*((pt1.x-pt2.x)/(pt1.y-pt2.y))
    else:
        start.x = centerX
        start.y = beginning.y
        end.x = centerY
        end.y = end.y
    voronoiLines.append(Line(start, end))
    return Line(Point(start.x, start.y), Point(end.x, end.y))
예제 #2
0
def drawPerpendicular(pt1, pt2, w):
    centerX = (pt1.x + pt2.x) / 2
    centerY = (pt1.y + pt2.y) / 2
    leftsize = 10
    rightsize = 10
    start = Point(0, 0)
    end = Point(0, 0)
    if pt1.y - pt2.y != 0:
        start.x = centerX - leftsize
        start.y = centerY + leftsize*((pt1.x-pt2.x)/(pt1.y-pt2.y))
        end.x = centerX + rightsize
        end.y = centerY - rightsize*((pt1.x-pt2.x)/(pt1.y-pt2.y))
        #print(centerX - 1, centerY + ((pt1.x-pt2.x)/(pt1.y-pt2.y)), " to ", centerX + 1, centerY - ((pt1.x-pt2.x)/(pt1.y-pt2.y)))
    else:
        start.x = centerX
        start.y = centerY + leftsize
        end.x = centerX
        end.y = centerY - rightsize
    w.create_line(start.x, start.y, end.x, end.y, fill="red", width=1)
    voronoiLines.append(Line(start, end))