simulating steel ball collision

Official forum for the Chipmunk2D Physics Library.
Post Reply
drcCoder
Posts: 3
Joined: Tue Feb 16, 2010 2:00 pm
Contact:

simulating steel ball collision

Post by drcCoder »

Hey,
I'm trying to simulate two steel balls, same size and mass, hanging from strings colliding with one another. One ball is at rest and the other hits it. What I'd like to happen is that when the moving ball hits the at rest ball it transfers its speed to the other ball and stops moving. At the moment the ball that collides continues to move but a bit slower. Any suggestions would be appreciated.
Last edited by drcCoder on Tue Feb 16, 2010 4:24 pm, edited 1 time in total.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: simulating steel ball collision

Post by slembcke »

Do the collision shapes have 1.0 for their elasticity? You will also need a lot of iterations to simulate this well.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
drcCoder
Posts: 3
Joined: Tue Feb 16, 2010 2:00 pm
Contact:

Re: simulating steel ball collision

Post by drcCoder »

This is where I set up the values for the ball sprites

Code: Select all

		mySprite.position = ccp(x,y);
		myBody = cpBodyNew(100.0f, cpMomentForCircle(100.0f, 0.0f, 25.0f, CGPointZero));
		myBody->p = ccp(x, y);

		cpSpaceAddBody(game->space, myBody);

		myShape = cpCircleShapeNew(myBody,25,CGPointZero); 
		myShape->e = 1; 
		myShape->u = 0;
		myShape->collision_type =1;
And these are the value set for the space they're in

Code: Select all

		space->gravity = ccp(0, -15000);
		space->elasticIterations = 0;
		space->iterations = 20;
		space->damping = 0.85;
drcCoder
Posts: 3
Joined: Tue Feb 16, 2010 2:00 pm
Contact:

Re: simulating steel ball collision

Post by drcCoder »

So, would anyone have any suggestions on how to make this work better.
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests