I have created two animations:
One where a "camera" moves towards the spheres creating an optic flow (1st GIF).The code can be found here.
One where spheres move randomly in a 3D coordinates space (2nd GIF). To do so I have computed two angles theta and phi. The code can be found here.
I need to compute the speed of each sphere frame by frame in both animations, but I have no idea of the mathematics. I would assume that the formula would be different in the two animations. I have found only the calculation of 3D velocity, and I was wondering whether I could calculate the speed as a single value?