def get_brace_points(offset_value, offset_member, brace_CL, brace_vector, offset_dir='+'): offset_brace = offset_line(brace_CL, offset_value) if offset_dir == '+': offset_brace_signed = offset_line(brace_CL, offset_value - self.offset) elif offset_dir == '-': offset_brace_signed = offset_line(brace_CL, offset_value + self.offset) else: raise ValueError brace_member_int = intersection_line_line_xy( offset_brace, offset_member) brace_pt = translate_points_xy([brace_member_int], brace_vector)[0] pt_mirrored = mirror_points_line([brace_pt], brace_CL) line_segment = Line(brace_pt, pt_mirrored) pt_CL = intersection_line_line_xy(line_segment, brace_CL) pt_distance = distance_point_point(self.work_point, pt_CL) return line_segment, pt_distance, offset_brace, offset_brace_signed
def test_translate_points_xy(): assert translate_points_xy([[0, 1, 2]], [3, 4, 5]) == [[3, 5, 0.0]]
# ============================================================================== # Main # ============================================================================== if __name__ == "__main__": import doctest import compas from compas.datastructures import Mesh from compas.datastructures import meshes_join from compas.geometry import translate_points_xy m1 = Mesh.from_obj(compas.get('faces.obj')) m2 = m1.copy() points = m2.vertices_attributes('xyz') x, y, z = zip(*points) xmin = min(x) xmax = max(x) points = translate_points_xy(points, [1.5 * (xmax - xmin), 0, 0]) for key, attr in m2.vertices(True): attr['x'] = points[key][0] attr['y'] = points[key][1] attr['z'] = points[key][2] m3 = meshes_join([m1, m2]) doctest.testmod()
def gusset_points(self): ''' Gusset points defined in Q1 of XY plane: all transformation done wrt this system. ''' pt0 = list(Point(self.eb, self.ec)) pt1 = translate_points_xy([pt0], Vector(self.width, 0, 0))[0] pt2 = translate_points_xy([pt1], Vector(0, self.offset, 0))[0] pt6 = translate_points_xy([pt0], Vector(0, self.height, 0))[0] pt5 = translate_points_xy([pt6], Vector(self.offset, 0, 0))[0] # Brace CL brace_vector = Vector(sin(radians(self.design_angle)), cos(radians(self.design_angle)), 0) brace_vector.unitize() brace_vector.scale(100) brace_pt = translate_points_xy([self.work_point], brace_vector)[0] test = brace_vector.copy() test.scale(1) brace_pt_out = translate_points_xy([self.work_point], test)[0] brace_CL = Line(self.work_point, brace_pt) self.gusset_lines.append(Line(self.work_point, brace_pt_out)) brace_vector.unitize() brace_vector.scale(self.connection_length) # Brace shoulder lines brace_depth = self.get_brace_depth() column_offset = brace_depth * 0.5 + self.offset beam_offset = -(brace_depth * 0.5 + self.offset) column_line = Line(pt5, Point(pt5[0], 0, 0)) beam_line = Line(pt2, Point(0, pt2[1], 0)) self.gusset_lines.append(column_line) self.gusset_lines.append(beam_line) def get_brace_points(offset_value, offset_member, brace_CL, brace_vector, offset_dir='+'): offset_brace = offset_line(brace_CL, offset_value) if offset_dir == '+': offset_brace_signed = offset_line(brace_CL, offset_value - self.offset) elif offset_dir == '-': offset_brace_signed = offset_line(brace_CL, offset_value + self.offset) else: raise ValueError brace_member_int = intersection_line_line_xy( offset_brace, offset_member) brace_pt = translate_points_xy([brace_member_int], brace_vector)[0] pt_mirrored = mirror_points_line([brace_pt], brace_CL) line_segment = Line(brace_pt, pt_mirrored) pt_CL = intersection_line_line_xy(line_segment, brace_CL) pt_distance = distance_point_point(self.work_point, pt_CL) return line_segment, pt_distance, offset_brace, offset_brace_signed column_line, col_dist, os_brace_column, os_column = get_brace_points( column_offset, column_line, brace_CL, brace_vector, offset_dir='+') beam_line, beam_dist, os_brace_beam, os_beam = get_brace_points( beam_offset, beam_line, brace_CL, brace_vector, offset_dir='-') self.gusset_lines.append(os_brace_column) self.gusset_lines.append(os_brace_beam) self.gusset_lines.append(os_column) self.gusset_lines.append(os_beam) self.gusset_lines.append(column_line) self.gusset_lines.append(beam_line) if col_dist > beam_dist: pt3 = column_line[1] pt4 = column_line[0] else: pt3 = beam_line[0] pt4 = beam_line[1] # TODO: set check to make sure gusset is non concave # (i.e. force points to line between pt2 and pt5) # Points list to point pt0 = Point(pt0[0], pt0[1], pt0[2]) pt1 = Point(pt1[0], pt1[1], pt1[2]) pt2 = Point(pt2[0], pt2[1], pt2[2]) pt6 = Point(pt6[0], pt6[1], pt6[2]) pt5 = Point(pt5[0], pt5[1], pt5[2]) self._gusset_points = [pt0, pt1, pt2, pt3, pt4, pt5, pt6] return self._gusset_points
def get_gusset_pts_and_guidelines(self): pt0 = list(Point(self.eb, self.ec)) pt1 = translate_points_xy([pt0], Vector(self.width, 0, 0))[0] pt2 = translate_points_xy([pt1], Vector(0, self.offset, 0))[0] pt6 = translate_points_xy([pt0], Vector(0, self.height, 0))[0] pt5 = translate_points_xy([pt6], Vector(self.offset, 0, 0))[0]