Springs
Spring simulation as a method to attract an object (such as a peice of text) to a target point. Using Hookes law of elasticity for a linear spring gives
F = -kx
So if we assume that the spring goes between two points p and q where p is the particle moving at velocity v and q the fixed target and the spring has a rest length of 0, and that ks = the spring const and kd = the spring damping const and where dx = the distance between p and q as a vector then the force on the particle p is
fp = -ks * dx - kd * v
and acceleration of the particle a = fp / mp (newtons third law, mp mass of particle p)
Then using a verlet integration scheme pi+1 = 2pi + pi-1 + a * dt2 (where dt is the change in time between pi+1 and pi) the movement of the particles can be easily calculated.
Empirical observations:
The quality of movement is controlled by the spring constants. The spring strength ks controls the speed and size of the oscillation, while the damping constant kd controls the degree of bounce and the time taken to converge on the target.
The fastest rate of convergence to the target occurs when the ration between damping and spring strength is around 1.2
I’ve also tried using functions for modifying spring strength or damping with time. Such as gradually ramping up the spring strength, so that when a new target is selected the old image doesn’t fly apart explosively, or if it is bouncing too much and not settling down then the damping increases after a certain time.
In occular coincidences I initally tried a single spring and damping constant, and then tried randomly values for all particles. Neither were terribly satisfactory, one led to the particles pulsing in step, the other to a random cloud. In the end I tried assigning just four or five different values so that groups of the particles pulsed together giving some cohesion without being too random. To get the words to twist rather than simulating a model of angular momentum as I did in the original memetic variations two springs are used for each animated word, with two target points calculated from the angle that the word is supposed to be placed at. This means that a vector can be calculated from the two springs to determine an angle at each time step. Addittionaly the distance between the two spring anchors could be used to calculate the size of the text. If multiple springs were used this way (say one for each letter) with slightly different spring constants then wobbly writhing text could be created as I’ve done in stories about you to place the text onto contours.