-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAula8_3.py
38 lines (30 loc) · 937 Bytes
/
Aula8_3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pygame, sys
import numpy as np
from pygame.locals import *
pygame.init()
pygame.display.set_caption("Aula 8 3")
DISPLAYSURF = pygame.display.set_mode((400,300))
WHITE = (255, 255, 255)
angulo=10
theta = np.radians(angulo)
#Matriz de rotação
R = np.matrix([[np.cos(theta), -1*np.sin(theta)],
[np.sin(theta), np.cos(theta)]])
p0 = [200, 150]
p1 = [150, 200]
p2 = [250, 200]
while True: #Main loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.draw.line(DISPLAYSURF, WHITE, p0, p1, 1)
pygame.draw.line(DISPLAYSURF, WHITE, p1, p2, 1)
pygame.draw.line(DISPLAYSURF, WHITE, p2, p0, 1)
p0_linha=np.matmul(R,p0)
p0= [p0_linha[0,0], p0_linha[0,1]]
p1_linha=np.matmul(R,p1)
p1= [p1_linha[0,0], p1_linha[0,1]]
p2_linha=np.matmul(R,p2)
p2= [p2_linha[0,0], p2_linha[0,1]]
pygame.display.update()