def test_line_vertexes_in_points(self): p1 = Pose(0, 0) p2 = Pose(1, 0) points = get_points_in_line(p1, p2, self.total_points) self.assertTrue( any([ draw_figure._are_points_equal(p, p1, self.dist_delta) for p in points ])) self.assertTrue( any([ draw_figure._are_points_equal(p, p2, self.dist_delta) for p in points ]))
def test_figure_vertexes_in_key_points(self): f = [Pose(0, 0), Pose(1, 0), Pose(0.5, 1)] points = get_figure_key_points(f, self.inter_vertexes_points) for vertex in f: self.assertTrue( any([ draw_figure._are_points_equal(p, vertex, self.dist_delta) for p in points ]))
def points_match_figure(figure, points, inter_vertexes_points, cross_delta, dist_delta): # For the points to correctly represent a figure, two conditions must be true: # a) All key points of the figure must have at least one corresponding point close to them for kp in get_figure_key_points(figure, inter_vertexes_points): if not any( [draw_figure._are_points_equal(p, kp, dist_delta) for p in points]): return False # b) All points must lie between two vertexes of the figure for p in points: if not any([ point_between_points( p, figure[n], figure[(n + 1) % len(figure)], cross_delta, dist_delta) for n in range(len(figure)) ]): return False return True
def test_barely_different_points(self): self.assertFalse( draw_figure._are_points_equal(Pose(0, 0), Pose(self.tolerance, self.tolerance), self.tolerance))
def test_barely_equal_points(self): self.assertTrue( draw_figure._are_points_equal( Pose(0, 0), Pose(self.tolerance / 2, self.tolerance / 2), self.tolerance))