Inputting parametric equations as a path for an object in Pygame results in different behaviour than expected.
I'm trying something out for a small game in writing in Python. I wanted to try having a sprite move in the shape of butterfly curve. Butterfly Curve
I've written the parametric equations for x and y, but plotting it results in something else.My butterfly
I'm unable to figure out why this is happening, but if I'd have to guess, there could be a problem with how Pyhon is running the code. The figure isn't entirely symmetric, so maybe the problem is with Python executing the code at different points in time, skewing the behaviour? Or maybe this is a sensitivity issue, where the input needs to be very precise for the behaviour to occur as expected? Either way, I thought this was really interesting, and I hope someone can point me in the right direction to start thinking about this problem.
def butterfly_move(self):
t = math.radians(pg.time.get_ticks() / 100)
"""Parametric equations for the butterfly curve"""
x = math.sin(t) * (math.exp(math.cos(t) - (2*(math.cos(4*t)) + pow(math.sin(t/12),5))))
y = math.cos(t) * (math.exp(math.cos(t) - (2*(math.cos(4*t)) + pow(math.sin(t/12),5))))
self.direction = pg.math.Vector2(x,y)
self.rect.center += self.direction * 20