
from fractions import Fraction

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __str__(self):
        return "(%s,%s)" % (self.x, self.y)
    def __repr__(self):
        return "(%s,%s)" % (self.x, self.y)

def midpoint(p1, p2):
    return Point(Fraction(p1.x + p2.x,2),Fraction(p1.y + p2.y,2))

def slope(p1, p2):
    return Fraction(p2.y - p1.y, p2.x - p1.x)

def perp_bisector(p1, p2):
    mp = midpoint(p1,p2)
    nrsl = -1 / slope(p1, p2)  # negative reciprocated slope(this will slope of perpendicular bisector)
    y_intercept = mp.y - nrsl*mp.x
    return "P1 " + str(p1) + "\t" + "P2 " + str(p2) + "\tMidpoint " + str(mp) + "\n" + \
        u"\ty = " + str(nrsl.numerator) + "/" + str(nrsl.denominator) + "x + " + str(y_intercept.numerator) + "/" + str(y_intercept.denominator)

p1 = Point(2, 4)
p2 = Point(4, -8)
p3 = Point(-6, -2)
p4 = Point(4, 8)
p5 = Point(-2, -10)
p6 = Point(10, 0)

"""
print perp_bisector(p1, p2)
print perp_bisector(p1, p3)
print perp_bisector(p1, p4)
print perp_bisector(p1, p5)
print perp_bisector(p1, p6)
"""
"""
print perp_bisector(p2, p3)
#print perp_bisector(p2, p4)
print perp_bisector(p2, p5)
print perp_bisector(p2, p6)
"""
"""
print perp_bisector(p3, p4)
print perp_bisector(p3, p5)
print perp_bisector(p3, p6)
"""
"""
print perp_bisector(p4, p5)
print perp_bisector(p4, p6)
"""
print perp_bisector(p4, p6)
