def click_calculate(self): self.logger.log("Calculate clicked") if self.get_button_calculate_state() == "disabled": return def str_to_point(s): return [float(el) for el in s.split()] line1 = Line(str_to_point(self._point1), str_to_point(self._point2)) line2 = Line(str_to_point(self._point3), str_to_point(self._point4)) self._result = self.RESULT_STR % (str(Line.is_intersect(line1, line2))) self.logger.log(self._result)
def test_can_det_if_point_and_line_segment_intersect_1(self): line1 = Line((0, 0), (0, 0)) line2 = Line((-0.05, -0.05), (0.1, 0.1)) self.assertTrue(Line.is_intersect(line1, line2))
def test_can_det_if_line_segments_with_common_edges_intersect(self): line1 = Line((0, 0), (0.1, 0.1)) line2 = Line((0.05, 0), (0.1, 0.1)) self.assertTrue(Line.is_intersect(line1, line2))
def test_can_det_if_equal_points_intersect(self): point = Line((0.1, -0.1), (0.1, -0.1)) self.assertTrue(Line.is_intersect(point, point))
def test_can_det_if_unequal_points_do_not_intersect(self): point1 = Line((0, 0), (0, 0)) point2 = Line((0.1, 0.1), (0.1, 0.1)) self.assertFalse(Line.is_intersect(point1, point2))
def test_can_det_if_parallel_lines_with_common_edge_intersect(self): line1 = Line((0, 0), (1, 1)) line2 = Line((1, 1), (3, 3)) self.assertTrue(Line.is_intersect(line1, line2))
def test_can_det_if_not_overlapping_parallel_lines_do_not_intersect(self): line1 = Line((0, 0), (1, 1)) line2 = Line((-2, -2), (-3, -3)) self.assertFalse(Line.is_intersect(line1, line2))
def test_can_det_if_equal_lines_intersect(self): line1 = Line((0, 0), (1, 0)) line2 = Line((0, 0), (1, 0)) self.assertTrue(Line.is_intersect(line1, line2))
def test_can_det_if_overlapping_lines_intersect(self): line1 = Line((0, 0), (1, 0)) line2 = Line((0.5, 0), (1.5, 0)) self.assertTrue(Line.is_intersect(line1, line2))
def test_can_det_if_two_parallel_lines_do_not_intersect(self): line1 = Line((0, 0), (1, 0)) line2 = Line((0, 1), (1, 1)) self.assertFalse(Line.is_intersect(line1, line2))
def test_points_of_created_line_are_float_numbers(self): point1 = (3.0, 2.0) point2 = (5, 2.0) line = Line(point1, point2) self.assertIsInstance(line.point2[0], float)
def test_can_create_line_if_args_are_correct(self): point1 = (3.0, 2.0) point2 = (1.0, 2.0) line = Line(point1, point2) self.assertTrue(point1 == line.point1 and point2 == line.point2)
def test_can_det_intersection_if_float_numbers_are_large(self): line1 = Line((0, 0), (0, 1e10)) line2 = Line((0, 1e10), (0, 2e10)) self.assertTrue(Line.is_intersect(line1, line2))