Пример #1
0
            msg="Se ha detectado un golpe en el dispositivo"
            popupmsg(msg)
        if mensaje_4int == 3.0 and mensaje_anterior4 == 0.0:
            if Sensor_d2==False:
                msg = "Se ha inhabilitado el movimiento del brazo"
                popupmsg(msg)

            if Sensor_d2 == True:
                msg = "Se ha habilitado el movimiento del brazo"
                popupmsg(msg)
            Sensor_d2 = not Sensor_d2
        if Sensor_d2 == True:
            n=0; m=0


        ua_image, ua_rect = upperarm.rotate(n)
        ua_rect.center += np.asarray(origin)
        ua_rect.center -= np.array([-np.cos(upperarm.rotation) * upperarm.offset,
                                    np.sin(upperarm.rotation) * upperarm.offset])
        fa_image, fa_rect = forearm.rotate((n+m))
        h_image, h_rect = hand.rotate((n+m))

        # generate (x,y) positions of each of the joints
        joints_x = np.cumsum([0,
                              upperarm.scale * np.cos(upperarm.rotation),
                              forearm.scale * np.cos(forearm.rotation),
                              hand.length * np.cos(hand.rotation)]) + origin[0]
        joints_y = np.cumsum([0,
                              upperarm.scale * np.sin(upperarm.rotation),
                              forearm.scale * np.sin(forearm.rotation),
                              hand.length * np.sin(hand.rotation)]) * -1 + origin[1]
Пример #2
0
height = 750
display = pygame.display.set_mode((width, height))
fpsClock = pygame.time.Clock()

upperarm = ArmPart('upperarm.png', scale=.7)
forearm = ArmPart('forearm.png', scale=.8)
hand = ArmPart('hand.png', scale=1.0)

origin = (width / 2, height / 2)

while 1:

    display.fill(white)

    # rotate our joints
    ua_image, ua_rect = upperarm.rotate(.03) 
    fa_image, fa_rect = forearm.rotate(-.02) 
    h_image, h_rect = hand.rotate(.03) 

        # generate (x,y) positions of each of the joints
    joints_x = np.cumsum([0, 
                          upperarm.scale * np.cos(upperarm.rotation),
                          forearm.scale * np.cos(forearm.rotation),
                          hand.length * np.cos(hand.rotation)]) + origin[0]
    joints_y = np.cumsum([0, 
                          upperarm.scale * np.sin(upperarm.rotation),
                          forearm.scale * np.sin(forearm.rotation), 
                          hand.length * np.sin(hand.rotation)]) * -1 + origin[1]
    joints = [(int(x), int(y)) for x,y in zip(joints_x, joints_y)]

    def transform(rect, base, arm_part):
Пример #3
0
pygame.init()

width = 500
height = 500
display = pygame.display.set_mode((width, height))
fpsClock = pygame.time.Clock()

upperarm = ArmPart('upperarm.png', scale=.7)

base = (width / 2, height / 2)

while 1:

    display.fill(white)

    ua_image, ua_rect = upperarm.rotate(.01) 
    ua_rect.center += np.asarray(base)
    ua_rect.center -= np.array([np.cos(upperarm.rotation) * upperarm.offset,
                                -np.sin(upperarm.rotation) * upperarm.offset])

    display.blit(ua_image, ua_rect)
    pygame.draw.circle(display, black, base, 30)

    # check for quit
    for event in pygame.event.get():
        if event.type == pygame.locals.QUIT:
            pygame.quit()
            sys.exit()

    pygame.display.update()
    fpsClock.tick(30)
Пример #4
0
def transform(rect, base, arm_part):
    rect.center += np.asarray(base)
    rect.center += np.array([
        np.cos(arm_part.rotation) * arm_part.offset,
        -np.sin(arm_part.rotation) * arm_part.offset
    ])


def transform_lines(rect, base, arm_part):
    transform(rect, base, arm_part)
    rect.center += np.array([-rect.width / 2.0, -rect.height / 2.0])


hand_rot = 1.57
ua_image, ua_rect = upperarm.rotate(1.57)
fa_image, fa_rect = forearm.rotate(3.14)
h_image, h_rect = hand.rotate(hand_rot)

while 1:

    display.fill(white)

    # rotate our joints
    ua_image, ua_rect = upperarm.rotate(0.)
    fa_image, fa_rect = forearm.rotate(0.)

    hand_rot = .03
    print(np.degrees(hand.rotation))
    if np.degrees(hand.rotation) >= 180:
        h_image, h_rect = hand.rotate(-1.57)
Пример #5
0
white = (255, 255, 255)
pygame.init()
width = 500
height = 500
display = pygame.display.set_mode((width, height))
fpsClock = pygame.time.Clock()
upperarm = ArmPart('upperarm.png', scale=.7)

base = (width / 2, height / 2)

while 1:

    display.fill(white)
    tecla = sys.stdin.read(1)
    if tecla == 'a':
        ua_image, ua_rect = upperarm.rotate(-.1)
        ua_rect.center += np.asarray(base)
        ua_rect.center -= np.array([
            -np.cos(upperarm.rotation) * upperarm.offset,
            np.sin(upperarm.rotation) * upperarm.offset
        ])

    if tecla == 'h':
        ua_image, ua_rect = upperarm.rotate(.1)
        ua_rect.center += np.asarray(base)
        ua_rect.center -= np.array([
            -np.cos(upperarm.rotation) * upperarm.offset,
            np.sin(upperarm.rotation) * upperarm.offset
        ])
    #ua_rect.center -= np.array([np.cos(upperarm.rotation) * upperarm.offset,
    #                            -np.sin(upperarm.rotation) * upperarm.offset])