Distributed Mass Spring-based Physics-Part 1- The Basics

By cactus1 a.k.a Officer Papaya a.k.a Spudster24 a.k.a cactus1234

Distributed mass physics utilizes realistic springs to simulate realistic motion. In this article, I will show the derivation of an algorithm to perform this task in real-time.

Springs follow Hooke's law, which is that the amount of force the spring exerts is proportional to its displacement from its rest length. In one-dimensional space, this is easily defined as F=k(x-r), where F is the force, k is the Hooke's constant, the spring's stiffness, x is the coordinate of one of the ends, and r is the restlength. Unfortunately, this simple equation does not retain its simplicity to three-dimensional physics.

The formulation of requires a bit more intensive math than that of the one-dimensional version. If the endpoints of the springs are represented as vectors v1 and v2, the length of the stretched string is |v1-v1|. Thus, the amount of stretching the string is undergoing is |v1-v1|-r. This is a scalar, and must be turned into a vector to calculate the force. In order to do this, you can multiply it by the normalized vector of its length, v1-v2/|v1-v2|.When multiplying these two factors, the two |v1-v2| cancel out, producing the equation

F1=-k(v1-v2-r(v1-v2)/||v1-v2|)
F2=k(v1-v2-r(v1-v2)/||v1-v2|)

A spring with distributed mass can be considered divided into infintisimally small springs, each exerting a force on the spring's endpoints based on the formula above, and each having masses at its endpoints. The entire spring may be considered stretched uniformly for simplicity. Thus the force each of these divisions will be 1/n-th the force if the entire spring were treated as a spring.

Force is relevant in some situations, but acceleration is required to calculate the time evolution of any system. The accleration can be found by intergrating the force formula after dividing it completely by the density function. This yields the equation

a1=∫L0p(x)-1u dx+dx

Now that the exact acceleration of the spring is known for that brief moment of time, the velocity and location changes can now be computed. The common numerical approximation of time evolution denotes the acceleration as constant during a single time frame. Otherwise, complex differential equations are involved in the calculations of the position and velocity equations. Considering acceleration is the first derivative of velocity and the second of position, integration will yield the correct formulas. v(t)=∫a dt=at+C. C is the initial velocity before the time frame, and t can be found to be the length of the timeframe. Thus, v(t)=atframe+vprev. The position is the accleration integrated doubly, s(t)=∫∫a dt=at2/2+C1t+C2. C1 is the initial velocity, and C2 is the initial position. Thus the equations are

s(t)=atframe2/2+vprevt+sprev
v(t)=at+vprev