Jesse-V / Folding-Atomata

3D simulation viewer for Folding@home
17 stars 6 forks source link

Non-linear frame interpolation #39

Open proteneer opened 11 years ago

proteneer commented 11 years ago

OK here's something fun to do.

Usually the .JSON frames are written once every say 25000 steps (at least for core17), and if you just animate frame by frame, the resulting sequence is going to look very choppy. A cool and neat thing to do is to do interpolation so that the transition looks smooth. There is no easy way to do this unfortunately, this is because you can't do simply do a linear interpolation in Euclidean space. Since proteins move by varying their torsion angles:

ie. given two frames X,Z, one can try to interpolate linearly:

X---->Y---->Z

but in reality, the bonds are constrained and proteins can only move via torsion angles:

    _->Y-_
X--/      \-->Z

so a linear interpolation is going to basically be breaking all sorts of stuff. If X and Z are separated very far in time, then there's basically no way to go from X to Z via interpolation.

This is a long term TODO.

PS (Sorry for spamming your issues list, I know you have a ton of things on here already =) )

Jesse-V commented 11 years ago

Here's how it currently works: Atomata uses an ordinary uniprocessor update-render loop. Every time update is called, it's passed the amount of milliseconds since update was last called. The SlotViewer class then uses this information to determine where the atoms and bonds should be positioned between the current pair of snapshots, with an elapsed time of 0 meaning position at snapshot 0, and 2000 ms meaning position at snapshot 1. This is linear interpolation. After the two seconds has passed, it switches to linearly interpolate between snapshot 1 and snapshot 2, and so on. Once it reaches (N-1, N), it then switches to (0, 1) again. So there is linear interpolation, so that atoms appear to move in a linear direction, but suddenly change direction once a new snapshot is used.

I think there are smooth equations that can be created via numerical approximations on the points available. For example, a polynomial could be developed for each atom to follow. That would make things much more smooth. This would be more accurate than the current approach, but not as accurate as what you're saying.

I'm not sure how to go about implementing your idea. What's your suggestion on the approach?

Usually I'm the one that spams my to-do list, and I don't mind, so feel free to carry on if you've got an idea. I may not get to everything right away, but each fixed ticket is an improvement. These are good ideas anyway. :)