[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - New at this and have a small issue

New at this and have a small issue

Official forum for the .

New at this and have a small issue

Postby swathen » Sun Feb 06, 2011 5:43 pm

Hello all,

I am fairly new at this, and in typical helloWorld fashion I have written a demo app that utilizes cocos2d, Chipmunk and spaceManager. I have had great
success up til now getting the desired effects (stacked house of cards collapses when hit by a bouncing ball, etc...). The last thing I tried to implement though doesn't work like its real world counterpart.

I wrote a quick app to simulate a Newton's Cradle. It has five cpCCSprites (mass 200, radius 20, elasticity .99 and friction 0.0), each hanging from a static anchor point (uses a pin joint). I have the anchor points spaced so the balls are just touching when at rest. When the user touches the screen an impulse is applied to the left most ball, and as expected it swings out to the left. The problem arises when it swings back down and contacts its neighbor. Instead of the rightmost ball shooting out on in arc and the whole cycle repeating, all four of the balls move out to a certain degree. It behaves as I would expect it to if the leftmost ball had more mass than the other four (sort of). After one swing back and forth they are all touching again and swinging in perfect synchronicity.

I have tried upping the elasticIterations and the steps to no avail. Anyone have any suggestions on parameters I could adjust to get this to work in a more realistic fashion.

Thanks in advance!!
swathen
 
Posts: 2
Joined: Sun Feb 06, 2011 5:13 pm

Re: New at this and have a small issue

Postby maximile » Sun Feb 06, 2011 6:10 pm

I had this working without too much fuss; see the end of this video: http://www.youtube.com/watch?v=I5N10c37Yb8

The only thing I did differently was to use pivot joints. This would stop any energy being spent rotating the balls around their middle, and I think I remember Scott saying they're a bit more stable.
maximile
 
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK

Re: New at this and have a small issue

Postby slembcke » Mon Feb 07, 2011 10:37 am

I guess if you want to make a "perfect" newton's cradle, you might want to cheat a bit more than you can with a real one. This can help make up for some of the inaccuracy that creeps in from using an imperfect discrete computer model of the physics.

Maximile's said, using a pivot joint will probably help so that you don't lose energy to rotation. That might also be happening because you set the friction to 0 which would normally help prevent it. Another suggestion would be to set the moment of inertia of the balls to infinity and use pin points. This might work even better, but is cheating a bit more. ;)

Also, don't use elastic iterations if you are using Chipmunk 5.2 or above, leave them set to 0. They are deprecated now and the simulation should work better without them. I figured out a slight change to Chipmunk that made them unnecessary. One thing to point out is that the collision impulse can only travel between one body each iteration. So if you have 5 balls, you need at least 4 iterations to pass the collision impulse on the the last ball.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: New at this and have a small issue

Postby swathen » Mon Feb 21, 2011 11:52 am

Thanks guys! The pivot joints were the trick. Works like a champ now.
swathen
 
Posts: 2
Joined: Sun Feb 06, 2011 5:13 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 0 guests

cron