def IsCenterOf(point, twod): name = twod.__class__.__name__ if name == 'circle': return Equals(point[0], twod.center[0]) & Equals(point[1], twod.center[1]) elif issubtype(name, 'polygon'): distances = [distance_between_points(point, each) for each in twod] reg = IsRegular(twod) out = reduce(operator.__and__, (Equals(distances[index-1], distance) for index, distance in enumerate(distances)), True) return reg & out else: raise Exception()
def IsRectLengthOf(number, quad): l1 = distance_between_points(quad[0], quad[1]) l2 = distance_between_points(quad[1], quad[2]) return Equals(l1, number) | Equals(l2, number)
def Isosceles(triangle): sides = [distance_between_points(triangle[index-1], point) for index, point in enumerate(triangle)] combs = itertools.combinations(sides, 2) out = reduce(operator.__or__, (Equals(a, b) for a, b in combs), False) return out
def Colinear(A, B, C): line = instantiators['line'](A, C) eq = Equals(LengthOf(line), distance_between_points(line.a, B) + distance_between_points(line.b, B)) return eq
def PointLiesOnCircle(point, circle): d = distance_between_points(point, circle.center) return Equals(d, circle.radius)