def place_large_triangle_90(self, point, node_open_num, base_arc1, base_arc2): #get_5_points_90(base_90_point, right_arc1, right_arc2): #base_90_point: 90度角顶点 #right_arc1: 直角边向量 point_45_1 = (point.pos[0] + base_arc1[0] * self.graph.basic_length * 2, point.pos[1] + base_arc1[1] * self.graph.basic_length * 2) #45度角顶点 point_45_2 = (point.pos[0] + base_arc2[0] * self.graph.basic_length * 2, point.pos[1] + base_arc2[1] * self.graph.basic_length * 2) hypotenuse_midpoint = ((point_45_1[0]+point_45_2[0])/2.0, (point_45_1[1]+point_45_2[1])/2.0) #斜边中点 right_midpoint_1 = ((point.pos[0]+point_45_1[0])/2.0, (point.pos[1]+point_45_1[1])/2.0) #直角边中点 right_midpoint_2 = ((point.pos[0] + point_45_2[0]) / 2.0, (point.pos[1] + point_45_2[1]) / 2.0) # 直角边中点 check_points = [] check_points.append(pic_process.get_middle_point_tri(point_45_1, hypotenuse_midpoint, right_midpoint_1)) check_points.append(pic_process.get_middle_point_tri(point_45_2, hypotenuse_midpoint, right_midpoint_2)) check_points.append(pic_process.get_middle_point_tri(point.pos, right_midpoint_1, right_midpoint_2)) check_points.append(pic_process.get_middle_point_tri(hypotenuse_midpoint, right_midpoint_1, right_midpoint_2)) vital_points = [point.pos, point_45_1, point_45_2, hypotenuse_midpoint, right_midpoint_1, right_midpoint_2] new_node = self.poly_place_getNewNode(check_points=check_points, vital_points=vital_points, node_open_num=node_open_num, shape_sign=self.LARGE_TRIANGLE) if new_node: vital_points = vital_points[:3] vital_points.sort() if new_node.large_triangle_1 == None: new_node.large_triangle_1 = vital_points else: new_node.large_triangle_2 = vital_points return [new_node] return []
def place_small_triangle_90(self, point, node_open_num, base_arc1, base_arc2): #get_2_points_90(base_90_point, right_arc1, right_arc2): #base_90_point: 90度角顶点 #right_arc1: 直角边向量 point_45_1 = (point.pos[0] + base_arc1[0] * self.graph.basic_length, point.pos[1] + base_arc1[1] * self.graph.basic_length) #45度角顶点 point_45_2 = (point.pos[0] + base_arc2[0] * self.graph.basic_length, point.pos[1] + base_arc2[1] * self.graph.basic_length) check_points = [] check_points.append(pic_process.get_middle_point_tri(point_45_1, point.pos, point_45_2)) vital_points = [point.pos, point_45_1, point_45_2] new_node = self.poly_place_getNewNode(check_points=check_points, vital_points=vital_points, node_open_num=node_open_num) if new_node: vital_points = vital_points[:3] vital_points.sort() if new_node.small_triangle_1 == None: new_node.small_triangle_1 = vital_points else: new_node.small_triangle_2 = vital_points return [new_node] return []
def place_large_triangle_45(self, point, node_open_num, base_arc1, base_arc2): node_open = self.open_all_list[node_open_num] def get_5_points_45(base_45_point, hypotenuse_arc, right_arc): #base_45_point: 45度角顶点 #hypotenuse_arc: 斜边向量 #right_arc: 直角边向量 other_45_point = (base_45_point.pos[0] + hypotenuse_arc[0] * self.graph.basic_length * (2 ** 0.5) * 2, base_45_point.pos[1] + hypotenuse_arc[1] * self.graph.basic_length * (2 ** 0.5) * 2) #另一个45度角顶点 hypotenuse_midpoint = ((base_45_point.pos[0]+other_45_point[0])/2.0, (base_45_point.pos[1]+other_45_point[1])/2.0) #斜边中点 right_point = (base_45_point.pos[0] + right_arc[0] * self.graph.basic_length * 2, base_45_point.pos[1] + right_arc[1] * self.graph.basic_length * 2) #直角顶点 right_midpoint = ((base_45_point.pos[0]+right_point[0])/2.0, (base_45_point.pos[1]+right_point[1])/2.0) #与point相邻直角边中点 far_right_midpoint = ((other_45_point[0] + right_point[0]) / 2.0, (other_45_point[1] + right_point[1]) / 2.0) # 远直角边中点 return [other_45_point, hypotenuse_midpoint, right_point, right_midpoint, far_right_midpoint] arcs = [base_arc1, base_arc2] new_nodes = [] for i in range(2): base_arc1 = arcs[i] base_arc2 = arcs[1-i] vital_points = get_5_points_45(point, hypotenuse_arc=base_arc1, right_arc=base_arc2) other_45_point, hypotenuse_midpoint, right_point, right_midpoint, far_right_midpoint = vital_points #pic_process.print_nodes(self.graph.pic_path, [point.pos]+vital_points, "large_tri_points.jpg") check_points = [] check_points.append(pic_process.get_middle_point_tri(point.pos, hypotenuse_midpoint, right_midpoint)) check_points.append(pic_process.get_middle_point_tri(right_point, far_right_midpoint, right_midpoint)) check_points.append(pic_process.get_middle_point_tri(hypotenuse_midpoint, other_45_point, far_right_midpoint)) check_points.append(pic_process.get_middle_point_tri(hypotenuse_midpoint, far_right_midpoint, right_midpoint)) vital_points = [point.pos, other_45_point, right_point, hypotenuse_midpoint, far_right_midpoint, right_midpoint] new_node = self.poly_place_getNewNode(check_points=check_points, vital_points=vital_points, node_open_num=node_open_num, shape_sign=self.LARGE_TRIANGLE) if new_node: vital_points = vital_points[:3] vital_points.sort() if new_node.large_triangle_1 == None: new_node.large_triangle_1 = vital_points else: new_node.large_triangle_2 = vital_points new_nodes.append(new_node) return new_nodes
def place_parallelogram_45(self, point, node_open_num, base_arc1, base_arc2): def get_3_points_45(base_45_point, hypotenuse_arc, right_arc): #base_45_point: 45度角顶点 #hypotenuse_arc: 斜边向量 #right_arc: 直角边向量 close_135_point = (base_45_point.pos[0] + hypotenuse_arc[0] * self.graph.basic_length, base_45_point.pos[1] + hypotenuse_arc[1] * self.graph.basic_length) #较近的135度角顶点 far_135_point = (base_45_point.pos[0] + right_arc[0] * self.graph.basic_length * (2**0.5), base_45_point.pos[1] + right_arc[1] * self.graph.basic_length * (2**0.5)) #较远的135度角顶点 far_45_point = (base_45_point.pos[0] + hypotenuse_arc[0] * self.graph.basic_length + right_arc[0] * self.graph.basic_length * (2 ** 0.5), base_45_point.pos[1] + hypotenuse_arc[1] * self.graph.basic_length + right_arc[1] * self.graph.basic_length * (2 ** 0.5)) # 较远的45度角顶点 return [close_135_point, far_135_point, far_45_point] arcs = [base_arc1, base_arc2] new_nodes = [] for i in range(2): base_arc1 = arcs[i] base_arc2 = arcs[1-i] vital_points = get_3_points_45(point, hypotenuse_arc=base_arc1, right_arc=base_arc2) close_135_point, far_135_point, far_45_point = vital_points #pic_process.print_nodes(self.graph.pic_path, [point.pos]+vital_points, "large_tri_points.jpg") check_points = [] check_points.append(pic_process.get_middle_point_tri(point.pos, close_135_point, far_135_point)) check_points.append(pic_process.get_middle_point_tri(far_45_point, close_135_point, far_135_point)) vital_points = [point.pos, close_135_point, far_45_point, far_135_point] new_node = self.poly_place_getNewNode(check_points=check_points, vital_points=vital_points, node_open_num=node_open_num) if new_node: vital_points = vital_points[:4] new_node.parallelogram = vital_points new_nodes.append(new_node) return new_nodes
def place_square_90(self, point, node_open_num, base_arc1, base_arc2): #get_5_points_90(base_90_point, right_arc1, right_arc2): #base_90_point: 90度角顶点 #right_arc1: 直角边向量 point_near_1 = (point.pos[0] + base_arc1[0] * self.graph.basic_length, point.pos[1] + base_arc1[1] * self.graph.basic_length) #与point相邻的顶点 point_near_2 = (point.pos[0] + base_arc2[0] * self.graph.basic_length, point.pos[1] + base_arc2[1] * self.graph.basic_length) opposite_point = (point.pos[0] + base_arc1[0] * self.graph.basic_length + base_arc2[0] * self.graph.basic_length, point.pos[1] + base_arc1[1] * self.graph.basic_length + base_arc2[1] * self.graph.basic_length) #与point相对的顶点 check_points = [] check_points.append(pic_process.get_middle_point_tri(point_near_1, opposite_point, point.pos)) check_points.append(pic_process.get_middle_point_tri(point_near_2, opposite_point, point.pos)) vital_points = [point.pos, point_near_1, opposite_point, point_near_2] new_node = self.poly_place_getNewNode(check_points=check_points, vital_points=vital_points, node_open_num=node_open_num) if new_node: vital_points = vital_points[:4] new_node.square = vital_points return [new_node] return []
def place_small_triangle_45(self, point, node_open_num, base_arc1, base_arc2): def get_2_points_45(base_45_point, hypotenuse_arc, right_arc): #base_45_point: 45度角顶点 #hypotenuse_arc: 斜边向量 #right_arc: 直角边向量 other_45_point = (base_45_point.pos[0] + hypotenuse_arc[0] * self.graph.basic_length * (2 ** 0.5), base_45_point.pos[1] + hypotenuse_arc[1] * self.graph.basic_length * (2 ** 0.5)) #另一个45度角顶点 right_point = (base_45_point.pos[0] + right_arc[0] * self.graph.basic_length, base_45_point.pos[1] + right_arc[1] * self.graph.basic_length) #直角顶点 return [other_45_point, right_point] arcs = [base_arc1, base_arc2] new_nodes = [] for i in range(2): base_arc1 = arcs[i] base_arc2 = arcs[1-i] vital_points = get_2_points_45(point, hypotenuse_arc=base_arc1, right_arc=base_arc2) other_45_point, right_point = vital_points #pic_process.print_nodes(self.graph.pic_path, [point.pos]+vital_points, "large_tri_points.jpg") check_points = [] check_points.append(pic_process.get_middle_point_tri(point.pos, other_45_point, right_point)) vital_points = [point.pos, other_45_point, right_point] new_node = self.poly_place_getNewNode(check_points=check_points, vital_points=vital_points, node_open_num=node_open_num) if new_node: vital_points = vital_points[:3] vital_points.sort() if new_node.small_triangle_1 == None: new_node.small_triangle_1 = vital_points else: new_node.small_triangle_2 = vital_points new_nodes.append(new_node) return new_nodes