Damping?

Discuss any Chipmunk bugs here.
Post Reply
User avatar
juanpi
Posts: 24
Joined: Wed Jan 30, 2008 3:52 pm
Contact:

Damping?

Post by juanpi »

Hi,
I found this line surfing through cpSpaceState

Code: Select all

cpFloat damping = pow(1.0f/space->damping, -dt);
line 503 cpSpace.c

Is this doing (1/space->damping)^(-dt)? This is just (space->damping)^dt
The first equation produces error for really small damping (like free space), while the seconds does not. I guess there is a reason for doing this, right?

Thanks
ker
Posts: 56
Joined: Tue Jul 15, 2008 4:13 am
Contact:

Re: Damping?

Post by ker »

correct me if I'm wrong, but the default value for cpSpace::damping is 1.0.
Therefore free space with no damping would have a damping value of 1.0 and 0.0 would be invalid.
This confused me at the beginning, too, since "no damping" would be 0.0 in my opinion and "full damping" 1.0.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Damping?

Post by slembcke »

Well, the thought was that you would be able to double the damping value to double the amount of damping. It is a bit confusing though.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
ker
Posts: 56
Joined: Tue Jul 15, 2008 4:13 am
Contact:

Re: Damping?

Post by ker »

but e.g. 0.3 would be really strong damping, and doubling it would be 0.6 which would be a lot less damping in the current setup, or at least that is how it feels to me
User avatar
juanpi
Posts: 24
Joined: Wed Jan 30, 2008 3:52 pm
Contact:

Re: Damping?

Post by juanpi »

Sorry guy,
Yes, you are write that damping 1.0 is no damping. What was the range for damping in the original design? Is 1.0 < damping < \infty, where damping= 1.0 means no damping or was it 0 < damping < 1, where 1 is fully damped?

Anyway, what I was trying to point out is that

pow(1.0f/damping, -dt)

is the same as

pow(damping,dt)

but you save 2 operations.

Thanks!

Do not miss the new videos in youtube! Magnets! :mrgreen:
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Damping?

Post by slembcke »

/me smacks forehead

Right. I see where you were going with that now.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests