def get_angle(self, index): index %= len(self.points) cur_p = self.points[index] prev_p = self.points[(index - 1) % len(self.points)] next_p = self.points[(index + 1) % len(self.points)] angle = Edge.angle_points(prev_p, cur_p, next_p) if next_p.classify(prev_p, cur_p) is symbols.left: angle = (math.pi * 2.0) - angle return angle
def test_angles(self): p2 = Point(1, 2) p1 = p2 + Point(4, 4) p3 = p2 + Point(-3, 3) self.assertAlmostEqual(Edge.angle_points(p1, p2, p3), math.pi / 2, delta=eps)