Example #1
0
def angle(a, b):
    ax = a.p2.x - a.p1.x
    ay = a.p2.y - a.p1.y
    bx = b.p2.x - b.p1.x
    by = b.p2.y - b.p1.y

    dot = e.dot_product(ax, ay, bx, by)
    len_a_squared = e.dot_product(ax, ay, ax, ay)
    len_b_squared = e.dot_product(bx, by, bx, by)

    return e.acos(dot / e.sqrt(len_a_squared * len_b_squared))
Example #2
0
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

        vx = p1.x - p2.x
        vy = p1.y - p2.y
        self.length = expressions.sqrt(expressions.dot_product(vx, vy, vx, vy))

        super(LineSegment, self).__init__([p1, p2], [])