In actionscript.org george.sch posted a question about the effect used in coke5 site. The leaves get pushed away when mouse goes near to them and come back when mouse moves away.
The behavior reminds a lot what I learned in school last time. Molecules attract and repel each other at the same time. The attraction and repulsion becomes stronger when the distance decreases and the forces weaken when the distance increases. However, the rate of increase and decrease for repulsion is much greater than the attraction. So, when two molecules are close to each other, both the attraction and repulsion are strong but repulsion is stronger than the attraction. As a result, the system shows that the molecules repel each other. When the two molecules are far apart from each other, both the repulsion and attraction are weak but the attraction is stronger than repulsion, so the system shows that the molecules attract each other. If the two molecules are too far way from each other, both attraction and repulsion are very weak and the system shows no interaction.
The real equation can be found at this website in the non-bonded energy part. And there’s some interesting information at this page
To implement in Flash, the calculation for attraction force is modified. It’s a simple easing equation, of the molecule has a tendency to go back to it’s original position. And here’s the example in AS3.0. The source is >>here<< (both AS2.0 and AS3.0).
This entry was posted
on Tuesday, May 15th, 2007 at 3:19 pm and is filed under Maths&Physics.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Might be interesting to give the repelling force a different field - instead of a simple circular drop-off (which could be visualized as a half-sphere if repelling force is graphed on z vs x,y coords), it could be more of a fluctuating wave pattern - that is a circular wave field that repells at outer sides of each wave period and slightly attracts at inner sides, and changes phase and dies down in amplitude as the mouse is no longer moved.
jake
Could you post just the actionscript or provide it in the zip file?
5566
hi guys, I’ve updated the attachment. now it’s in text format.
Might be interesting to give the repelling force a different field - instead of a simple circular drop-off (which could be visualized as a half-sphere if repelling force is graphed on z vs x,y coords), it could be more of a fluctuating wave pattern - that is a circular wave field that repells at outer sides of each wave period and slightly attracts at inner sides, and changes phase and dies down in amplitude as the mouse is no longer moved.
Could you post just the actionscript or provide it in the zip file?
hi guys, I’ve updated the attachment. now it’s in text format.
[…] Using molecular mechanics in Flash Cool motions based on equations of attraction and repulsion. […]
Damn that’s tasty. Thanks for the explanation, too. Really useful.
Thanks for the PM to this blog, and for the explanation of it all. Very, very cool and helpful.