def is_point_in_the_rectangle(self, point): for i in range(1, 5, 1): p0 = self.points[i % 4] p1 = self.points[(i + 1) % 4] p3 = self.points[(i + 3) % 4] angle1 = GeoOperations.get_angle_between_two_vectors(Point.Point(p3.x - p0.x, p3.y - p0.y), Point.Point(p1.x - p0.x, p1.y - p0.y)) angle2 = GeoOperations.get_angle_between_two_vectors(Point.Point(point.x - p0.x, point.y - p0.y), Point.Point(p1.x - p0.x, p1.y - p0.y)) angle3 = GeoOperations.get_angle_between_two_vectors(Point.Point(point.x - p0.x, point.y - p0.y), Point.Point(p3.x - p0.x, p3.y - p0.y)) if angle2 > angle1 or angle3 > angle1: return False return True
def get_area(self): point_num = len(self.points) point1 = self.points[0] area_sum = 0 for i in range(2, point_num, 1): point2 = self.points[i - 1] point3 = self.points[i] area_sum += GeoOperations.calculate_tri_area(point1, point2, point3) return area_sum