Exemplo n.º 1
0
 def construct(self):
     """
     """
     hw = 0.5 * self.width
     hh = 0.5 * self.height
     p = Point(-hw, hh)
     top = Line(p, p.move(self.width, 0.))
     c = top.end_point.move(hh, -90.)
     right = CircularArc(c, hh, 90., -180.)
     bot = right.connecting_line(self.width)
     left = CircularArc(c.move(self.width, 180.), hh, -90., -180.)
     return locals()
Exemplo n.º 2
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)