I am a big fan of dave whytes vector animations like this one it was generated using a special animation language called processing here is daves codewhile it seems powerful processing it is not very elegant in my opinion this post shows how to do similar animations using two python libraries gizeh for the graphics and moviepy for the animations. I dont know what you meant with your variables vector and distance but imo their names should be swappedin your code vector is the length of the diff vector which is calculated using pythagoras theorem d2 dx2 dy2 d sqrtdx2 dy2 in your code there is the distance variable which is the position vector only normalized divided by its own length. Python is a great object oriented and interactive programming language that lets you develop graphics both static and animated using built in vector graphics functions that are provided with python python 26 graphics cookbook is a collection of straightforward recipes and illustrative screenshots for creating and animating graphic objects . Python has some great data visualization librairies but few can render gifs or video animations this post shows how to use moviepy as a generic animation plugin for any other library moviepy lets you define custom animations with a function make framet which returns the video frame corresponding to time t in seconds
How it works:
1. Register Trial Account.
2. Download The Books as you like ( Personal use )