Esempio n. 1
0
 def draw_wings(self, offset):
     """Draw the hanging metal wings with the screw holes.
     """
     w = 0.5 * (self.outer_width - self.inner_width) - self.corner_radius
     l = self.wing_length - 2. * self.corner_radius
     p = Point(0.5 * self.wing_length, 0.5 * self.inner_width)
     Line(p, p.vmove(w)).draw(offset).\
         connecting_circular_arc(self.corner_radius, 90.).draw(offset).\
         connecting_line(l).draw(offset).\
         connecting_circular_arc(self.corner_radius, 90.).draw(offset).\
         connecting_line(w).draw(offset)
     p = Point(0.5 * self.wing_length, -0.5 * self.inner_width)
     Line(p, p.vmove(-w)).draw(offset).\
         connecting_circular_arc(-self.corner_radius, -90.).draw(offset).\
         connecting_line(-l).draw(offset).\
         connecting_circular_arc(-self.corner_radius, -90.).draw(offset).\
         connecting_line(-w).draw(offset)
Esempio n. 2
0
 def draw(self, offset):
     """
     """
     radius = 0.5 * self.inner_length
     a = self.outer_length - self.inner_length
     b = 0.5 * (self.width - self.flat_width) - radius
     theta = (-b + np.sqrt(b**2. + 2 * a * radius)) / radius
     l = np.sqrt((a + 0.5 * radius * theta**2.)**2. +
                 (b + radius * theta)**2.)
     p = Point(0., 0.5 * self.width - radius)
     line = CircularArc(p, radius, 0., 180. - np.degrees(theta)).draw(offset).\
         connecting_line(l).draw(offset)
     p = line.end_point()
     Line(p, p.vmove(-self.flat_width)).draw(offset)
     p = Point(0., -0.5 * self.width + radius)
     line = CircularArc(p, radius, 0., -180. + np.degrees(theta)).draw(offset).\
         connecting_line(l).draw(offset)
     p = p.hmove(0.5 * self.inner_length)
     Line(p, p.vmove(self.width - 2. * radius)).draw(offset)
Esempio n. 3
0
def test_draw(offset):
    """
    """
    blueprint(f'EJ #1{offset}', 'A3', orientation='Portrait')
    #body = Body()
    #body.draw(offset)

    x = np.array([
        0., 15., 50., 125., 200., 230., 250., 280., 300., 325., 350., 370.,
        385., 400., 405., 395., 384., 380.5, 379., 383., 393., 375., 354.,
        340., 320., 305., 298.7, 315., 334.7, 325.8, 310., 266., 230., 200.,
        120., 50., 10.
    ])
    y = np.array([
        0., 80., 131., 160., 141.5, 124.3, 113.3, 106.4, 107.4, 115., 123.,
        125.7, 123., 110.3, 90., 68., 57., 50., 42., 28., 10., -13.2, -27.5,
        -28.58, -30.5, -40.5, -60., -90, -108.7, -122.5, -127.4, -115.1,
        -116.2, -136., -159.4, -131., -69.
    ])
    s = ParametricSpline(x, y)
    s.draw(offset)
    #s.draw_points(offset)

    #scale = 1.05
    #s1 = ParametricSpline(x * scale, y * scale)
    #s1.draw(offset - Point(8., 0.))

    h1 = 52.
    h2 = 25.
    w1 = 75.
    x, y = s.calculate_contour(offset, tmin=0., tmax=0.5)
    mask = abs(y - offset.y) > h1
    x = x[mask]
    y = y[mask]
    plt.plot(x, y, color='black')
    plt.hlines(h1 + offset.y, x[0], x[-1])

    x, y = s.calculate_contour(offset, tmin=0.5, tmax=1.)
    mask = np.logical_and(abs(y - offset.y) > h1, x - offset.x < 317.)
    x = x[mask]
    y = y[mask]
    plt.plot(x, y, color='black')
    plt.hlines(-h1 + offset.y, x[0], x[-1])

    p0 = Point(-50., 0.)
    l = Line(p0, p0.move(500., 0.))
    l.draw(offset)

    p1 = Point(200., -200.)
    l = Line(p1, p1.vmove(400.))
    l.draw(offset)
Esempio n. 4
0
 def draw(self, offset):
     """Overloaded method.
     """
     self._draw_contour(self.inner_length, self.inner_width, offset)
     self._draw_contour(self.inner_length, self.outer_width, offset)
     if self.outer_length != self.inner_length:
         w = 0.5 * self.inner_width - 0.25 * self.inner_length
         d = 6.
         p1 = Point(-0.5 * self.inner_length, w)
         p2 = Point(p1.x - self.outer_length + self.inner_length, d)
         p3 = p2.vmove(-2. * d)
         p4 = Point(-0.5 * self.inner_length, -w)
         Line(p1, p2).draw(offset)
         Line(p2, p3).draw(offset)
         Line(p3, p4).draw(offset)
     self.draw_magnets(offset)
     self.draw_screw_holes(offset)