I’m trying to write a little physics simulation using only standart Pygame. I wanna to have a trapezoid a draw it using 4 dots. So I wanna to rotate every single of this dots independetly (not use pygame.transform.rotate
). I write a code that calculate a new coordinates of dot, after rotation around a pivot, using trigonometric functions.
fps = 15
clock = pygame.time.Clock()
x1 = 150
y1 = 150
x = x1
y = y1
p = 250
q = 250
angle = 10
theta = math.radians (angle)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
clock.tick(fps)
screen.fill ((0,0,0))
screen.set_at ((p,q),(255,0,0))
pygame.draw.circle (screen, (255,0,0), (x,y), 10)
x = p + math.cos(theta) * (x - p) - math.sin(theta) * (y - q)
y = q + math.sin(theta) * (x - p) + math.cos(theta) * (y - q)
pygame.display.update()
pygame.display.flip()
But when I run it, dot perform not circular move, but goes a spiral down to a pivot. I look at coordinates in first frame, and they just a little bit different from what I expect.

How to fix this? I wanna a circular movement.