Пример #1
0
    def extrusion_area(self):
        from ada.core.vector_utils import calc_yvec, intersect_calc, is_parallel

        area_points = []
        vpo = [np.array(p) for p in self.points]
        p2 = None
        yvec = None
        prev_xvec = None
        prev_yvec = None
        zvec = np.array([0, 0, 1])

        # Inner line
        for p1, p2 in zip(vpo[:-1], vpo[1:]):
            xvec = p2 - p1
            yvec = unit_vector(calc_yvec(xvec, zvec))
            new_point = p1 + yvec * (self._thickness / 2) + yvec * self.offset
            if prev_xvec is not None:
                if is_parallel(xvec, prev_xvec) is False:
                    prev_p = area_points[-1]
                    # next_point = p2 + yvec * (self._thickness / 2) + yvec * self.offset
                    # c_p = prev_yvec * (self._thickness / 2) + prev_yvec * self.offset
                    AB = prev_xvec
                    CD = xvec
                    s, t = intersect_calc(prev_p, new_point, AB, CD)
                    sAB = prev_p + s * AB
                    new_point = sAB
            area_points.append(new_point)
            prev_xvec = xvec
            prev_yvec = yvec

        # Add last point
        area_points.append((p2 + yvec * (self._thickness / 2) + yvec * self.offset))
        area_points.append((p2 - yvec * (self._thickness / 2) + yvec * self.offset))

        reverse_points = []
        # Outer line
        prev_xvec = None
        prev_yvec = None
        for p1, p2 in zip(vpo[:-1], vpo[1:]):
            xvec = p2 - p1
            yvec = unit_vector(calc_yvec(xvec, zvec))
            new_point = p1 - yvec * (self._thickness / 2) + yvec * self.offset
            if prev_xvec is not None:
                if is_parallel(xvec, prev_xvec) is False:
                    prev_p = reverse_points[-1]
                    c_p = prev_yvec * (self._thickness / 2) - prev_yvec * self.offset
                    new_point -= c_p
            reverse_points.append(new_point)
            prev_xvec = xvec
            prev_yvec = yvec

        reverse_points.reverse()
        area_points += reverse_points

        new_points = []
        for p in area_points:
            new_points.append(tuple([float(c) for c in p]))

        return new_points
Пример #2
0
def get_thick_normal_from_channel_beams(section: Section, cog, normal, placement: Placement) -> ShellProfileComp:
    aligned_with_web = is_parallel(normal, placement.xdir)
    if aligned_with_web is True:
        return ShellProfileComp(SectionParts.WEB, section.t_w, normal)
    aligned_with_flange = is_parallel(normal, placement.ydir)
    if aligned_with_flange is True:
        cog_vec = placement.origin - np.array(cog)
        res = np.dot(placement.zdir, cog_vec)
        if res < 0:
            return ShellProfileComp(SectionParts.TOP_FLANGE, section.t_ftop, normal)
        else:
            return ShellProfileComp(SectionParts.BTN_FLANGE, section.t_fbtn, normal)

    raise ValueError(f"Unable to identify {section.type} shell entity to correct section property")
Пример #3
0
        def modify_beam(bm: Beam, new_nodes) -> Beam:
            n1, n2 = new_nodes

            n1_2_n2_vector = unit_vector(n2.p - n1.p)
            beam_vector = bm.xvec.round(decimals=Settings.precision)

            if is_parallel(n1_2_n2_vector, bm.xvec) and not is_null_vector(
                    n1_2_n2_vector, bm.xvec):
                n1, n2 = n2, n1
            elif not is_parallel(n1_2_n2_vector, bm.xvec):
                raise ValueError(
                    f"Unit vector error. Beam.xvec: {beam_vector}, nodes unit_vec: {-1 * n1_2_n2_vector}"
                )

            bm.n1, bm.n2 = n1, n2
            return bm
Пример #4
0
    def member_type(self):
        from ada.core.vector_utils import is_parallel

        xvec = self.xvec
        if is_parallel(xvec, [0.0, 0.0, 1.0], tol=1e-1):
            mtype = "Column"
        elif xvec[2] == 0.0:
            mtype = "Girder"
        else:
            mtype = "Brace"

        return mtype
Пример #5
0
 def is_equal_beamtype(item) -> bool:
     return isinstance(
         item, Beam) and self.is_equivalent(item) and is_parallel(
             self.xvec, item.xvec)
Пример #6
0
def get_thick_normal_from_box_beams(section: Section, cog, normal, placement: Placement) -> ShellProfileComp:
    aligned_with_web = is_parallel(normal, placement.xdir)
    if aligned_with_web is True:
        return ShellProfileComp(SectionParts.WEB, section.t_w, normal)
    else:
        return ShellProfileComp(SectionParts.BTN_FLANGE, section.t_fbtn, normal)