Author Topic: 2D Collision  (Read 515772 times)

pleasedontgocrazy

  • Newbie
  • *
  • Posts: 4
topic4
« Reply #15 on: October 23, 2005, 11:42:16 pm »
what if the collision isnt perfectly inelastic/ elastic

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
topic4
« Reply #16 on: October 24, 2005, 08:45:39 am »
You just need to solve the problem differently for non- perfect elastic collision.

Momentum is still conserved. But the energy is not conserved.

pleasedontgocrazy

  • Newbie
  • *
  • Posts: 4
topic4
« Reply #17 on: October 25, 2005, 06:39:17 pm »
I keep trying to prove your equation by using the assumption that kinetic energy is not lost and momentum is not lost but I keep getting a different answer to yours. Could you give me some pointers about how to do solve it. SOLVED!

Im doing this experiment for my A level coursework and I found that typically 90% of the mommentum is lost. Have I made a mistake?

pleasedontgocrazy

  • Newbie
  • *
  • Posts: 4
topic4
« Reply #18 on: October 25, 2005, 07:56:26 pm »
Yes! Ive solved it (and got the correct answer)

But this is for an elastic collision. For an partial inelastic collision which equation do I use for kinetic energy? Do you lose a certain amount of energy or is it a percentage of energy lost?

SIBUK

  • Newbie
  • *
  • Posts: 1
Sticky Balls
« Reply #19 on: November 28, 2005, 06:52:53 am »
Hi Professor Hwang,

This article is fantastic and has helped me a lot, but I am wondering if you might be able to help me out with a problem I have. I have made a program where I have multiple balls on the screen, each moving at a random velocity and in a random direction.

 The problem I have is that when 2 balls collide, they will often stick to each other (especially when ed is < 1) and spin around orbiting each other. Each of the balls has a radius of 15, and so my collision detection is very simple, when the distance between two balls is <= 30 then there has been a collision. So, the problem is that when the distance is less than 30, (say 25), then they are overlaping by 5, when I next update the positions of the balls, if they havnt moved more than a distance of 5 away from each other since the last update, then they are still overlapping and the collision is still true. So, what I need to do is before the next update, I need to move the balls appart from each other a distance of 5 in the new direction after the impact. But I cant seem to figure out the maths to do it.

Also, I have implemented a bit of code to help handle when 3 or more balls collide at the same time, but it doesnt quite seem to work right. Do you have any tips for this?

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
topic4
« Reply #20 on: April 15, 2006, 03:11:56 pm »
The real collision should have occured before you detected that the distance between two center of the balls d is less than the sum of those two balls r1+r2.

The correct way is to find the time when the two ball real collide with each other.
Suppose the center of those two ball are x1,y2 and x2,y2
dx=x2-x1, dy=y2-y1; d=sqrt(dx*dx+dy*dy);

First calculate the component of velocity in the direction of (dx,dy)
vp1= vx1 *dx/d+vy1*dy/d;
vp2= vx2*dx+vy2*dy/d;

Collision should have happened dt before you have detected r1+r2<d;

 and dt =(r1+r2-d)/(vp1+vp2);

So you should move those two ball backward
 x1-= vx1*dt;
 y2 -= vy1*dt;
 x2-=vx2*dt;
 y2-=vy2*dtl

Now the distance between center of the two balls is d'=r1+r2;

Apply the collision to calculate new velocity for those two balls after collision.
Support new velocity are vx1' , vy1', vx2',vy2'

You need to move time dt forward
so

  x1+= vx1'*dt;
  y1+=vy1'*dt;
  x2+=vx2'*dt;
  y2+=vy2'*dt;


You can check out another simulation created with EJS and find out how I did it with EJS.

druidbartek

  • Guest
Re: 2D Collision
« Reply #21 on: February 21, 2007, 04:49:40 am »
hi
sorry for bumping this old thread but ive some problems with ball collision (in C)
the - the conservation of kinetic energy is property but not the conservation of momentum :(
it's the simple ball collision 2D for old nokia mobiles
static void redraw_screen(void)
{
  /* ... */
  ball_collision(&app.ball_a, &app.ball_b);
  <redraw_screen>
}
static void ball_collision(struct ball *ball_a, struct ball *ball_b)
{
  float dx = ball_b->x - ball_a->x;
  float dy = ball_b->y - ball_a->y;
  float d = sqrt(dx*dx+dy*dy);

  if(d<=(float)bmap_ball.height) // r1+r2 = bmap_ball.height
  {
  // first we calculate the velocity in the direction of (dx,dy)
  float vp_a = (ball_a->vx*dx + ball_a->vy*dy)/d;
  float vp_b = (ball_b->vx*dx + ball_b->vy*dy)/d;

  // collision should have happened dt before
  float dt =((float)bmap_ball.height-d)/(vp_a-vp_b);

  // we should move those ball backward
  ball_a->x -= ball_a->vx*dt;
  ball_a->y -= ball_a->vy*dt;
  ball_b->x -= ball_b->vx*dt;
  ball_b->y -= ball_b->vy*dt;

  dx = ball_b->x - ball_a->x;
  dy = ball_b->y - ball_a->y;
  d = sqrt(dx*dx+dy*dy);

  // calculate the components of velocity
  float ap = dx/d;
  float an = dy/d;

  vp_a = ball_a->vx*ap + ball_a->vy*an;
  float vn_a = ball_a->vx*an - ball_a->vy*ap;

  vp_b = ball_b->vx*ap + ball_b->vy*an;
  float vn_b = ball_b->vx*an - ball_b->vy*ap;
 
  // calculate new velocity for those balls after collision
  ball_a->vx = vp_b*ap + vn_a*an;
  ball_a->vy = vp_b*an - vn_a*ap;
  ball_b->vx = vp_a*ap + vn_b*an;
  ball_b->vy = vp_a*an - vn_b*ap;

  // now we need to move time dt forward
  ball_a->x += ball_a->vx*dt;
  ball_a->y += ball_a->vy*dt;
  ball_b->x += ball_b->vx*dt;
  ball_b->y += ball_b->vy*dt;
  }
}

and im stuck  ???

regards,
Bartek


oh, and mass1 = mass2 and eta =1
« Last Edit: February 21, 2007, 05:14:57 am by druidbartek »

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: 2D Collision
« Reply #22 on: February 22, 2007, 05:48:24 pm »
This is the java code I use in my simulation:
  r12=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
cs=(x2-x1)/r12; sc=(y2-y1)/r12;
vp1=vx1*cs+vy1*sc;
vp2=vx2*cs+vy2*sc;
// back to collision time
ddt=(dmin-r12)/(vp1-vp2);
if(ddt>dt)ddt=0.;
x1-=vx1*ddt; y1-=vy1*ddt;
x2-=vx2*ddt; y2-=vy2*ddt;
r12=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
//calculate component of velocity
cs=(x2-x1)/r12; sc=(y2-y1)/r12;
vp1=vx1*cs+vy1*sc;
vp2=vx2*cs+vy2*sc;
//  normal components do not change
vn1=vx1*sc-vy1*cs;
vn2=vx2*sc-vy2*cs;
  //calculate component of velocity in original X,Y coordinate
px1=vp1*cs; py1=vp1*sc;
px2=vp2*cs; py2=vp2*sc;
nx1=vn1*sc; ny1=-vn1*cs;
nx2=vn2*sc; ny2=-vn2*cs;
}

solashok

  • Newbie
  • *
  • Posts: 1
Re: 2D Collision
« Reply #23 on: February 28, 2007, 10:22:43 am »
Respected Sir,
  when two atoms collide using Conservation of Momentum and Energy we get expression for E2 = 4M1M2 cos square phi E0/(M1 + M2)square. Can U suggest me how this has come.

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: 2D Collision
« Reply #24 on: February 28, 2007, 11:15:32 am »
What is the situation you want to discuss about? There is no way to discuss if question is not well defined!
What are the meaning for E0,E2 and what is the formula you want to show?
And how did you get that formula? ???
 

mrsdost

  • Newbie
  • *
  • Posts: 2
Re: 2D Collision
« Reply #25 on: April 19, 2007, 12:13:41 am »
Hello Professor,
I am currently working on the following question and was wondering if you could offer any help. I'm just not sure how to factor in the 30 degrees. this is of course a completely elastic collision. any help would be great.
Thanks,
mrsdost

Two pool balls are rolling along a pool table. The red pool ball has a velocity of 10 cm/s west and the blue ball a velocity of 10 cm/s north 30° east. What are the velocities of the balls after the collision?

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: 2D Collision
« Reply #26 on: April 19, 2007, 02:01:41 am »
You can find out the answer easily.
Just use mouse to drag the velocity vector for each ball in the simulation (conditions match with your problem) and find out the answer by yourself!

mrsdost

  • Newbie
  • *
  • Posts: 2
Re: 2D Collision
« Reply #27 on: April 19, 2007, 10:55:36 pm »
Thank you Professor,
but i need to learn how to do the calculations myself.
So if you could help me with some formulas that include the vectors of the balls that would be great.
Thank you,
Mrsdost

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: 2D Collision
« Reply #28 on: April 19, 2007, 11:09:51 pm »
Please look at all the forum messages in this topic carefully,  all the steps (in detail) have been posted.
I guess you did not read this forum messages carefully.
If you did read it and still did not understand it. Please at least indicate where you did not get it. ::)

arthurprs

  • Newbie
  • *
  • Posts: 10
Re: 2D Collision
« Reply #29 on: July 22, 2007, 02:41:57 am »
Hi professor, sorry to bother you, but im having some dificult here to make your code work  ???

This is my code in OPascal
not much dif from java
  dx := ball[i].cx - ball[n].cx;
  dy := ball[i].cy - ball[n].cy;
  dist := Sqrt(Power(dx, 2) + Power(dy, 2));
  if dist <= (ball[i].raio + ball[n].raio) then
  begin
  ax := dx / dist;
  ay := dy / dist;
  vp_n := (ball[n].vx * ax) + (ball[n].vy * ay);
  vp_i := (ball[i].vx * dx) + (ball[i].vy * ay);
  dt := ((ball[i].raio + ball[n].raio) - dist) / (vp_n + vp_i);
  ball[n].x := ball[n].x - (ball[n].vx * dt);
  ball[n].y := ball[n].y - (ball[n].vy * dt);
  ball[i].x := ball[i].x - (ball[i].vx * dt);
  ball[i].y := ball[i].y - (ball[i].vy * dt);

You can see something wrong ?

*sorry my bad english, im from brazil

EDIT: If u can send me the source code to my email it will be helpfull too
« Last Edit: July 22, 2007, 02:24:22 pm by arthurprs »