From ....../samples/CHOP/CHOP_Spring.C [gree...]:
d1 = block->myDn1;
d2 = block->myDn2;
// Loop over each sample in the track.
for(j=0; jgetTrackLength(); j++)
{
t = myClip->getTime(myClip->getStart() + j);
oldp = f = clip->evaluateSingleTime(track, t);
// Run the spring equation
if(!force_method)
f *= spring_constant;
else
oldp /=spring_constant;
vel = (d1-d2) / inc;
acc = (f - vel*damping_constant - d1*spring_constant)/mass;
vel += acc * inc;
d = d1 + vel * inc;
delta = SYSabs(oldp - d);
if (delta > 0.001)
mySteady = 0;
new_track->getData()[j] = d;
d2 = d1;
d1 = d;
}
// update the displacements in the realtime data block for the next cook
// to use.
block->myDn1 = d1;
block->myDn2 = d2;