Example #1
0
 def get_up_vectors(self):
     """ Finds the up_vectors of each point of the boundary. A smoothing step is also included. """
     up_vectors = []
     for i, p in enumerate(self.points):
         v1 = Vector.from_start_end(p,
                                    self.points[(i + 1) % len(self.points)])
         cross = v1.cross(self.normals[i])
         v = Vector(*normalize_vector(cross))
         if v[2] < 0:
             v.scale(-1)
         up_vectors.append(v)
     up_vectors = utils.smooth_vectors(up_vectors,
                                       strength=0.4,
                                       iterations=3)
     return up_vectors
Example #2
0
viewer.add(mesh,
           settings={
               'color': '#cccccc',
               'vertices.on': True,
               'edges.on': False,
               'opacity': 0.7,
               'vertices.size': 5
           })

for vertex in mesh.vertices():
    if mesh.is_vertex_on_boundary(vertex):
        continue

    point = Point(*mesh.vertex_coordinates(vertex))
    normal = Vector(*mesh.vertex_normal(vertex))
    c = curvature[vertex]
    normal.scale(10 * c)

    color = '#ff0000' if c > 0 else '#0000ff'

    viewer.add(Line(point, point + normal),
               settings={
                   'vertices.on': False,
                   'edges.color': color,
                   'edges.width': 3
               })

viewer.update()
viewer.show()
Example #3
0
    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