NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
October 21, 2017, 04:39:56 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
"It is not the strongest of the species that survive, but the one most responsive to change." ..."Darwin(1809-1882, English naturalist Evolution)"
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: 1 [2] 3 4 ... 6   Go Down
  Print  
Author Topic: 2D Collision  (Read 454608 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #30 on: July 23, 2007, 03:35:51 pm »

You can find out the code related to what you need from previous messages.
You are not following the same steps I did.
Please read it more carefully.

Logged
arthurprs
Newbie
*
Offline Offline

Posts: 10


«
Embed this message
Reply #31 on: July 24, 2007, 01:29:19 am »

You can find out the code related what you need from previous messages.
You are not following the same steps I did.
Please read it more carefully.
ok.
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #32 on: July 24, 2007, 03:04:13 pm » posted from:Taipei,T'ai-pei,Taiwan

Please following the code I did in my previous messages.
Post the code again if you still have the problem.
Logged
arthurprs
Newbie
*
Offline Offline

Posts: 10


«
Embed this message
Reply #33 on: July 26, 2007, 09:44:45 am »

Please following the code I did in my previous messages.
Post the code again if you still have the problem.

Hey professor i did it, but somethimes the balls don't colide right  Huh

anything wrong with my code ?

Code:
  for n := 0 to Length(ball)-1 do
  begin // n = currentball

  // wall hit
  //x
  if (ball[n].x <= 0)
  or (ball[n].x2 >= Form1.ClientWidth) then
  begin
  ball[n].vx := -ball[n].vx {* 0.9};
  end;
  //y
  if (ball[n].y <= 0)
  or (ball[n].y2 >= Form1.ClientHeight) then
  begin
  ball[n].vy := -ball[n].vy {* 0.9};
  end;

  // other balls hit
  for i := 0 to Length(ball)-1 do // i = other ball
  if ((i <> n) and (not (ball[i].colided)) and (not (ball[n].colided))) then
  begin
  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);
  ball[n].Refresh;
  ball[i].Refresh;
  //
  dx := ball[i].cx - ball[n].cx;
  dy := ball[i].cy - ball[n].cy;
  dist := Sqrt(Power(dx, 2) + Power(dy, 2));
  ax := dx / dist;
  ay := dy / dist;
  vp_n := ball[n].vx * ax + ball[n].vy * ay;
  vp_i := ball[i].vx * ax + ball[i].vy * ay;
  vn_n := ball[n].vy * ay - ball[n].vy * ax;
  vn_i := ball[i].vy * ay - ball[i].vy * ax;
  vn:= vp_n + (1+ed)*(vp_i - vp_n)/(1+ball[n].mass/ball[i].mass);
  vi:= vp_i + (1+ed)*(vp_n - vp_i)/(1+ball[i].mass/ball[n].mass);
  ball[n].vx:= vn*ax-vn_n*ay;
  ball[n].vy:= vn*ay+vn_n*ax;
  ball[i].vx:= vi*ax-vn_i*ay;
  ball[i].vy:= vi*ay+vn_i*ax;
  ball[n].Refresh;
  ball[i].Refresh;
  ball[n].colided:=True;
  ball[i].colided:=True;
  end;
  end;
  end;

  for n := 0 to Length(ball) - 1 do
  begin
  ball[n].Move;
  end;
end;

2 balls
both mass = 1 and ed = 1
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #34 on: July 26, 2007, 10:43:11 am »

You did not read my post carefully.
You did not do the following steps:

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

 and dt =(r1+r2-d)/(vp1+vp2);// the collision should have occurred at t-dt (Actually this is also an approximation).

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

Next : do the collision parts. as the normal case.

And move the time forward:

Because we have move time backward dt, we need to move time forward dt.
so
  x1+= vx1'*dt;
  y1+=vy1'*dt;
  x2+=vx2'*dt;
  y2+=vy2'*dt;

Now the distance between two ball will be larger than r1+r2.

Please read the following post carefully and follow all the steps.

http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=4.msg15#msg15
Logged
estruiz
Newbie
*
Offline Offline

Posts: 2

«
Embed this message
Reply #35 on: July 27, 2007, 05:30:46 am »

Hi Professor

My name is Esteban and I need some help.  I do not know much about physics, but this past year i've been trying to solve a head on collision between a 98 Dodge ram 1500 quad cab 4x4 (5251 lbs.) and a Pontiac Grand AM 4 door sedan (3650 lbs.).  The pontiac is heading south and the dodge is heading north.  The speed of the car is unknown and the speed of the truck is 43 mph +-.  No breaks where applied to neither vehicles.  The friction of the road is 0.565.  The car heading south crossed over the centerline at an angle of 14 degrees and when realized they where in the oncoming lane they tried to steer to their right which sent their car out of control and made their tail end slide sideways.  the car is still heading in the same 14 degrees, but now going sideway almost at 90 degrees to the 14 degree direction.  Both truck and car impact on the left front bumpers (driver side).  Both left front tires from each vehicle are locked.  The truck is sent backwards about 19 feet and its final resting position is facing east.  The car is sent east of the impact about 18 feet and about 8 feet north of the impact with the car facing south.  the dimensions of the road are 28 feet from edge of pavement to edge of pavement so 14 feet from centerline to EOP. The slope of the road heading south is S=1.45% south and the entire road slopes to the east at 2.75%. 

What I need to know if this is possible and if it is, at what speed does the car need to be traveling to be able to push back the truck?  Please email me if you need any more information at estruiz@msn.com
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #36 on: July 27, 2007, 09:20:00 am »

"the car is still heading in the same 14 degrees, but now going sideway almost at 90 degrees to the 14 degree direction."

I do not quite understand the above situation? And is it happened before the collision?

"The slope of the road heading south is S=1.45% south and the entire road slopes to the east at 2.75%.  "
I did not understand the above statement,either!

The car is sent east of the impact about 18 feet, But from center to edge of pavement is 14 feet, so the car is out of the pavement?

Without consider the above parameters. From the impact distance in the north-south direction.
I try to estimate the speed right after the impact for both car:
Assume the stopping distance are all due to friction of the road (which might not be true if car was flying after the impact)
The following are very rough estimation and base on  the above assumption:
acceleration for both car assume to be the same: a=-0.565*9.8=5.537 m/s^2

v=sqrt(2*a*s)=sqrt(2*9.8*0.565*s)
19 feet=5.79 m so the speed is about 8 m/s  So it took 1.4 s to fully stopped after the collision.
8 feet=2.43m so the speed is about 5.2m/s  So it took 0.9s to fully stopped after the collision.

Initial speed for the truck is 43mph=69km/hr=19.2m/s

Assume conservation of momentum during collision
3650*(v+5.2)=5251*(19.2+8) so v=33.9m/s = 122 km/hr= 75.9 mph (estimated speed for the car)

Because the mass for the car is smaller than the truck and the bounce off distance for the car is less than the truck, so the speed of the car is larger than the truck.
However, the above estimate are based on very simple model. I believe local police agent should have gather more data to provide a better estimation.
Logged
arthurprs
Newbie
*
Offline Offline

Posts: 10


«
Embed this message
Reply #37 on: July 28, 2007, 12:50:27 pm »

You did not read my post carefully.
You did not do the following steps:

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

 and dt =(r1+r2-d)/(vp1+vp2);// the collision should have occurred at t-dt (Actually this is also an approximation).

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

Next : do the collision parts. as the normal case.

And move the time forward:

Because we have move time backward dt, we need to move time forward dt.
so
  x1+= vx1'*dt;
  y1+=vy1'*dt;
  x2+=vx2'*dt;
  y2+=vy2'*dt;

Now the distance between two ball will be larger than r1+r2.

Please read the following post carefully and follow all the steps.

http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=4.msg15#msg15


yes i did it in lines 30 and 31 =/
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #38 on: July 28, 2007, 08:39:48 pm »

You are checking collision between n particles
with loop like
for(int i=0;i for(j=0;j }
}
In the above case, collision between particles might be processed twice.
You can change the loop to
for(int i=0;i for(j=0;j  if(i!=j){// particle can not collide with itself
  }
 }

And I did not fully understand what do you mean by
"somethimes the balls don't colide right  Huh"!
You only tell me you think there is something wrong, But I did not know what is wrong!


}
Logged
arthurprs
Newbie
*
Offline Offline

Posts: 10


«
Embed this message
Reply #39 on: July 29, 2007, 02:49:09 pm »

You are checking collision between n particles
with loop like
for(int i=0;i<n;i++){
 for(j=0;j<n;j++){
 }
}
In the above case, collision between particles might be processed twice.
You can change the loop to
for(int i=0;i<n;i++){
 for(j=0;j<i;j++){
  if(i!=j){// particle can not collide with itself
  }
 }

And I did not fully understand what do you mean by
"somethimes the balls don't colide right  Huh"!
You only tell me you think there is something wrong, But I did not know what is wrong!


}


the problem is that in 10% of colisions the backtime to make (distance = r1 + r2) does not work right and the ball keep inside the other one
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #40 on: July 29, 2007, 09:11:46 pm »

It is always difficult and take time to find out the bug, especially you are working with another language.

Did you change the setting in the loop for your code?
Did you make sure all the particles are not overlap with each other in the initial state?
If you can run  your code step by step, you might be able to find out bugs in your code.
I was assuming the distance moved between each time step is smaller than the size of the particle.
It might be your time step is too large or the velocity is too big. In that case, try to use a smaller time step.

The original source code for this java applet is attached.


*** There are 1 more attached files. You need to login to acces it!
Logged
arthurprs
Newbie
*
Offline Offline

Posts: 10


«
Embed this message
Reply #41 on: July 30, 2007, 08:27:32 am »

It is always difficult and take time to find out the bug, especially you are working with another language.

Did you change the setting in the loop for your code?
Did you make sure all the particles are not overlap with each other in the initial state?
If you can run  your code step by step, you might be able to find out bugs in your code.
I was assuming the distance moved between each time step is smaller than the size of the particle.
It might be your time step is too large or the velocity is too big. In that case, try to use a smaller time step.

The original source code for this java applet is attached.

ohh i thinks is the velocity its 1.5 in one ball and 1.3 on another  Huh

i will try Wink
Logged
estruiz
Newbie
*
Offline Offline

Posts: 2

«
Embed this message
Reply #42 on: July 31, 2007, 01:19:32 am »

From what I know the car went off the road and tried to get back on to his lane.  This caused the car to get out of control and went sideways at a 14 degree direction before the collision. 

yes the slope of the street heading south is S=1.45% down and the cross slope of the street is actually S=2.86% to the east from the west edge of pavment.

yes the car went outside of the pavment onto dirt shoulder which has a slope of around S=13% EAST
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #43 on: July 31, 2007, 09:07:57 am »

I did not take into account the slope of the road in my previous estimation. Since the car went outside the pavement and onto dirt shoulder which has a slope. The velocity of the car might be less than the estimated velocity.  However, it was a very rough estimation from the information I knew.
Logged
tedhuntington
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #44 on: August 31, 2007, 12:14:14 am »

The 2d collision description is easy to understand, thanks. What needs to be done to make it 3D? Is that a major difference? Do we just need to figure out the projection, perpendicular and one other component then?

thanks
Ted
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #45 on: August 31, 2007, 10:40:17 pm »

You can solve equations for the conservation of momentum and conservation of energy for 3D, and you will find out new relations (This will give you complicate equations).
However, for 2 particles collide, you can always define a 2D coordinate system (the plane formed by v1Xv2).
So it is always a 2D problem. You just need to find the projection of the 2D plane into 3D coordinate.(And this is the easiest way to do.)

Just like this 2D collision simulation. I transfered the problem into a two 1D problem. And it is make the problem simpler. (I did not solve the 2D problem directly.)

How to transfer a complicated problem into a simpler one, is one of the purpose for learning physics. Wink
Logged
Collidin Ideas
Newbie
*
Offline Offline

Posts: 1

«
Embed this message
Reply #46 on: October 08, 2007, 10:57:42 pm »

Hello Professor Fu-Kwun Hwang

I m currently developing a game JOGL(java opengl) in which multiple balls are present on the board n a striker is present using which we have to pot those other coins (Circular Disks) we have uptill now created the board n discs but we are stuck at collision detection part coz there are multiple discs involved

i have thought of creating an event which would detect collisions can u help us with how to go about it with multiple disks involved

thanking you in advance
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #47 on: October 09, 2007, 12:37:43 am »

If you have n balls, you need to set up two level loops to check if they are collide with each other
code might be similar to the following:
for(int i=0;i for(int j=i;j  check_collision(i,j,x,y);
 }
}
Logged
pepsicoder
Newbie
*
Offline Offline

Posts: 2

«
Embed this message
Reply #48 on: October 25, 2007, 10:15:57 pm »

Hi can you please help me my balls get pushed away abrubtly when colliding sometimes,im keeping my velocities less than my ball radiuses so it can not be that i have done loads of experimentation but no joy.  (cr=0.4;  mass=1;) 

please check my following code written in flash cs3 thankyou in advance.

for (var i1:uint=0;i1<BALLTOTAL-1;i1++) {
  for (var i2:uint=i1+1;i2<BALLTOTALL;i2++) {

  var dx:Number=cararray[i1].x-cararray[i2].x,
  dy:Number=cararray[i1].y-cararray[i2].y,
     d:Number=Math.sqrt(dx*dx+dy*dy),
    r1:Number=19,
    r2:Number=r1;
                        
  if (d<=(r1+r2)) {
                  
  // component of velocity in the direction (dx,dy)
  var vp1:Number=cararray[i1].velx*dx/d+cararray[i1].vely*dy/d,
  vp2:Number=cararray[i2].velx*dx/d+cararray[i2].vely*dy/d, // << corrected this line >>
     dt:Number=(r1+r2-d)/(vp1+vp2);
                     
  // move back
  cararray[i1].x-=cararray[i1].velx*dt;
  cararray[i1].y-=cararray[i1].vely*dt;
  cararray[i2].x-=cararray[i2].velx*dt;
  cararray[i2].y-=cararray[i2].vely*dt;
                  
  dx=cararray[i1].x-cararray[i2].x;
  dy=cararray[i1].y-cararray[i2].y;
  d=Math.sqrt(dx*dx+dy*dy);
                                 
  // unit vector in the direction of the collision 
  var ax:Number=dx/d , ay:Number=dy/d;
                                  
  // projection of the velocities
  var va1:Number=( cararray[i1].velx*ax+cararray[i1].vely*ay),
  vb1:Number=(-cararray[i1].velx*ay+cararray[i1].vely*ax),
     va2:Number=( cararray[i2].velx*ax+cararray[i2].vely*ay),
     vb2:Number=(-cararray[i2].velx*ay+cararray[i2].vely*ax);
                                 
  // new velocities after collisions 
  var vap1:Number=va1+(1+cr)*(va2-va1)/(1+cararray[i1].mass/cararray[i2].mass),
  vap2:Number=va2+(1+cr)*(va1-va2)/(1+cararray[i2].mass/cararray[i1].mass);
                           
  // undo the projections (new velocities after collision)
  cararray[i1].velx=vap1*ax-vb1*ay;
  cararray[i1].vely=vap1*ay+vb1*ax;
  cararray[i2].velx=vap2*ax-vb2*ay;
  cararray[i2].vely=vap2*ay+vb2*ax;
                  
  // move forward
  cararray[i1].x+=cararray[i1].velx*dt;
  cararray[i1].y+=cararray[i1].vely*dt;
  cararray[i2].x+=cararray[i2].velx*dt;
  cararray[i2].y+=cararray[i2].vely*dt;
  }
  }
}
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #49 on: October 26, 2007, 05:10:04 pm »

I am not familiar with the syntax in your code.
var i2:uint=i1+1;// Does it mean i2=i1+1;Huh I wrote some action code in flash before, but it was almost the same as java-script.

But the problem only occurred for some occasional case, so most part of the code should be all right.
When the ball was pushed away, is it with a much larger velocity?
If this is the case, you can add some code to print out related information when such case happened, in order to find out what went wrong.
Logged
Manav
Newbie
*
Offline Offline

Posts: 6


«
Embed this message
Reply #50 on: October 31, 2007, 10:09:20 am »

Hello Professor Hwang,

  You might have guessed my name, it's Manav. In my class we have been creating a class to emulate the physics aspect for a bouncing ball in C++ and using the glut class from OpenGL to show the ball. So far in our class we have many balls that can bounce and slow down due to gravity. I wanted to do more since I am a little bored and so I've been trying to mold your 2D collision of balls for my 3D collision for my balls. Since I registered with the forum just now (which by the way was very helpful for me to get started) I am having troubles. I am stuck at trying to do the part where you calculated the projection velocities, since I have to deal with 3 dimensional vectors. Help would be greatly appreciated. The following is the code for my collision procedure in my C++ class:

Code:
void BallObject::Collision(BallObject ball){
double r1 = diameter / 2; //first ball's radius
double r2 = ball.diameter / 2; //second ball' radius

double dx = ball.position[0] - position[0];
double dy = ball.position[1] - position[1];
double dz = ball.position[2] - position[2];

double d = sqrt((dx*dx) + (dy*dy) + (dz*dz));
double dt;

double vp1 = (velocity[0]*(dx/d)) + (velocity[1]*(dy/d)) + (velocity[2]*(dz/d));
double vp2 = (ball.velocity[0]*(dx/d)) + (ball.velocity[1]*(dy/d)) + (ball.velocity[2]*(dz/d));

if(r1 + r2 < d){
dt =(r1+r2-d)/(vp1+vp2);

position[0] -= velocity[0]*dt;
position[1] -= velocity[1]*dt;
position[2] -= velocity[2]*dt;

ball.position[0] -= ball.velocity[0]*dt;
ball.position[1] -= ball.velocity[1]*dt;
ball.position[2] -= ball.velocity[2]*dt;
  }
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #51 on: October 31, 2007, 07:38:53 pm »

For the code in the previous message, you just move those two ball back to the point where the collision occurred.
(The above solution is an approximation, it is not an exact solution. But it should work fine when the velocity*dt << size of the ball).
I do not know what can I help.
Logged
Manav
Newbie
*
Offline Offline

Posts: 6


«
Embed this message
Reply #52 on: November 01, 2007, 01:12:19 am »

Hi, its me again and the problem I'm having with is converting the following part for a 3 dimensional ball:

// Unit vector in the direction of the collision
double ax=dx/distance, ay=dy/distance;
// Projection of the velocities in these axes
double va1=(vx1*ax+vy1*ay), vb1=(-vx1*ay+vy1*ax);
double va2=(vx2*ax+vy2*ay), vb2=(-vx2*ay+vy2*ax);
// New velocities in these axes (after collision): ed<=1,  for elastic collision ed=1
double vaP1=va1 + (1+ed)*(va2-va1)/(1+mass1/mass2);
double vaP2=va2 + (1+ed)*(va1-va2)/(1+mass2/mass1);
// Undo the projections
vx1=vaP1*ax-vb1*ay;  vy1=vaP1*ay+vb1*ax;// new vx,vy for ball 1 after collision
vx2=vaP2*ax-vb2*ay;  vy2=vaP2*ay+vb2*ax;// new vx,vy for ball 2 after collision

In the above code you only deal with x, and y direction, but i want to try to also include a z direction as well and
I do not know how to do the calculation with x, y, and z direction since the ball I'm working on has an x, y, and z position vector.
 
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #53 on: November 01, 2007, 04:32:00 pm » posted from:Taipei,T\'ai-pei,Taiwan

I am going to assume you fully understand vector and the inner product between two vectors.

If there are vector A and another vector B. (use bold face to represent vector)

Let the unit vector of A is a=A/|A|, and b=B/|B|, where |A|, |B| are the length of A,B

You can calculate the projection of vector A in the direction of B with AB/|B| =Ab : where • mean inner product
In 2D, ax=dx/distance, ay=dy/distance so (ax,ay) is the unit vector in the direction between center of those two balls.
So the projection of velocity(vx,vy)  in the direction of (ax,ay) is  vx*ax+vy*ay
For the code:
ouble va1=(vx1*ax+vy1*ay), vb1=(-vx1*ay+vy1*ax);
double va2=(vx2*ax+vy2*ay), vb2=(-vx2*ay+vy2*ax);

Now, you know why va1,va2 can be calculated with the above formula.
vb1,vb2 are the normal components -- perpendicular to the (vx,vy)
So the unit vector is (-ay, ax)  -- (ax,ay)•(-ay,ax)=0 so those two vectors are perpendicular to each other.

For the 3D case, you just need to add another component (z) and calculate it in the same way.

I hope you can understand it. If not, let me know and I will try to explain it in more detail.
However,  I want you to understand it, so you will be able to solve similar problem next time. That is why I do not want to give you the exact solution. And you will be more confident when you can solve it by yourself.  You will enjoy the fun of learning this way,too!  Wink
Logged
Manav
Newbie
*
Offline Offline

Posts: 6


«
Embed this message
Reply #54 on: November 02, 2007, 01:03:21 am »

Thanks a lot professor Hwang,
  I finally incorporated the z axis into the calculation, but i have one final question. Could
you tell the reason for having dt and what it is doing to the balls in the program. And once again
THANK-YOU very much.
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #55 on: November 02, 2007, 09:09:03 am » posted from:Taipei,T\'ai-pei,Taiwan

It was explained in the previous message.
In the simulation (or computer programming), the time step is a finite step.
The collision should have happened (It should occurred when R1+R2=d),
before the program detect those two ball collided ( R1+R2 > d, where d is the distance between two balls, and R1,R2 are the radius).
So we calculate the relative velocity in the direction between center of two balld, and estimate the time collision should have happened (dt). So we move the ball back to the moment when the collision should have occurred (let the time move backward by dt, or let particle move backward by v*dt !). Do the calculation for collision, and move time step dt forward again .
Logged
Manav
Newbie
*
Offline Offline

Posts: 6


«
Embed this message
Reply #56 on: November 02, 2007, 10:35:35 am »

wow Shocked, so dt meant the time for the ball to have collided, I'm sorry i was confusing dt with
some sort of distance Embarrassed. Professor Hwang you have been an amazing teacher.
Thank-You  Grin

Also I was wondering should I post how i did the calculation for finding the final velocities of the two ball in
Three-dimension?
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #57 on: November 02, 2007, 09:46:30 pm »

You can decide it by yourself. It's all depend on what the purpose for the posting.
You can post it so that the other user can copy it for similar work, or you want other to do the calculation by herself/himself.
Logged
Manav
Newbie
*
Offline Offline

Posts: 6


«
Embed this message
Reply #58 on: November 02, 2007, 10:21:29 pm »

I guess I'll let people do the calculations by themselves since it turned out to be really
easy, but I'll give the other people a hint: When you calculate for a 2-d collision
you calculate for the normal vector and a tangent vector like how Professor Hwang
had done "Va1 and Va2 were calculated using the normal vector and Vb1 and Vb2
were calculated using". When you are calculating for a 3-d collision you have to
find i second tangent vector and just adjust the equations professor has to inclue
the z direction in (x, y, z). If you require more detail for an elastic 2-d collision
equations use the following site: http://www.geocities.com/vobarian/2dcollisions/2dcollisions.pdf

Please correct me if I am wrong and than-you.
 
Logged
Manav
Newbie
*
Offline Offline

Posts: 6


«
Embed this message
Reply #59 on: November 02, 2007, 10:24:16 pm »

I am really sorry people the following sentence from above should look like this:
"Va1 and Va2 were calculated using the normal vector and Vb1 and Vb2
were calculated using the tangent vector".

Once again I am sorry this is my first forum visit ever.
Logged
Pages: 1 [2] 3 4 ... 6   Go Up
  Print  
"It is not the strongest of the species that survive, but the one most responsive to change." ..."Darwin(1809-1882, English naturalist Evolution)"
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Collision 2D « 1 2 3 »
Dynamics
Fu-Kwun Hwang 64 134627 Last post April 11, 2011, 05:51:32 pm
by Fu-Kwun Hwang
Ejs open source java applet 1D collision carts Elastic and Inelastic Collision « 1 2 3 »
Collaborative Community of EJS
lookang 77 78830 Last post March 26, 2012, 04:05:27 pm
by lookang
4 car collision going through two intersections
Request for physics Simulations
Kennyg10 1 6767 Last post August 06, 2009, 11:51:32 am
by Fu-Kwun Hwang
1 D collision carts Elastic and Inelastic Collision
dynamics
ahmedelshfie 6 11359 Last post April 27, 2010, 02:16:18 am
by ahmedelshfie
Collision 2D
dynamics
ahmedelshfie 1 4612 Last post September 24, 2010, 07:22:37 pm
by ahmedelshfie
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.096 seconds with 23 queries.since 2011/06/15