Good day, I decided to simulate the harmonic oscillations of a mathematical pendulum in python3, through simple actions I received arrays of x and y coordinates of a body suspended by a thread, but I can’t deal with the graphic part, create the animation of the pendulum itself. I will be glad to any ideas.

The result of 2D, schematic, in the form of video, will be enough if I can run through the terminal on the linux. I looked at various libraries that could help me, even installed them, but I could not find anywhere an accessible guide on how to do this. In general, the idea is this: just fix one point of the line, and run the second along the array of coordinates.

  • Well, there is definitely either OpenCV or Pygame. There and there are functions to draw a line. In Pygame, you can draw and rotate sprites easily. - Mikhail V

1 answer 1

For animation, you can use the turtle library in it there are simple methods for drawing. You will have to manually render each step of the animation.

You can also use the matplotlib library, it has the ability to create animation using FuncAnimation . The library website has an example of a double pendulum animation