We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Simulating inertia (physics)
Page Index Toggle Pages: 1
Simulating inertia (physics)? (Read 589 times)
Simulating inertia (physics)?
Oct 24th, 2006, 4:32pm
 
Hi friends,
I'd like to simulate inertia in processing. As an example, I'd like an object to move up/down when I move the mouse pointer, and when the mouse pointer stops, the object would keep on moving for a while until it stops. I've seen this kind of effect used for scrollbars and such on the web.

How can I do that? I'm just starting at working with processing.
Re: Simulating inertia (physics)?
Reply #1 - Oct 25th, 2006, 4:49pm
 
Just in case someone is interested, i found this example out there regarding a similar idea on a flash movie:

inertia=0.9;
k=0.1;

x = -object.x + mouse.x
y = -object.y + mouse.y

xp = xp*inertia+x*k;
yp = yp*inertia+y*k;

object.x = object.x + xp;
object.y = object.y + yp;
Page Index Toggle Pages: 1