• Lucid Dreaming - Dream Views




    Results 1 to 16 of 16
    1. #1
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935

      Tell me how to solve this

      I've spent hours trying to figure this out. I'm building a particle engine for my thesis and I am having a hard time with this part of it.

      I have two particles colliding and I need to know their resulting trajectories.

      I know:

      Mass of both particles
      Velocities of both particles (both angle, magnitude and in vectors)
      I know the angle between them

      Attached is a diagram.

      The distance between the two and the radii of them need to be irrelevant.
      Attached Images

    2. #2
      On the woad to wuin R.D.735's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Mostly in my right hemisphere
      Posts
      340
      Likes
      0
      Is this collision perfectly elastic/inelastic?

      Don't forget that you can use conservation of momentum to help you solve it.

      I hope that helps.
      Last edited by R.D.735; 03-14-2008 at 06:35 PM.

    3. #3
      Member Achievements:
      1 year registered Veteran First Class 10000 Hall Points
      wasup's Avatar
      Join Date
      Oct 2003
      Gender
      Posts
      4,668
      Likes
      21
      I would help, but your picture is broken.

    4. #4
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Quote Originally Posted by R.D.735 View Post
      Is this collision perfectly elastic/inelastic?

      Don't forget that you can use conservation of momentum to help you solve it.

      I hope that helps.
      It's perfectly elastic; ie there is no friction from the particles bouncing off of each other. I'm trying to conserve momentum.

      Weird, the picture works fine for me. Here's an embedded one:
      Last edited by ninja9578; 03-14-2008 at 07:25 PM.

    5. #5
      Ad absurdum Achievements:
      1 year registered 1000 Hall Points Made lots of Friends on DV Referrer Bronze Veteran First Class
      Spartiate's Avatar
      Join Date
      Jul 2007
      Gender
      Location
      Block 4500-7000
      Posts
      4,825
      Likes
      1113
      I just get a red x, can you upload it on imageshack or something? Or maybe just write out the variables.

    6. #6
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      I mentioned all the variables

      Here is it on imageshack

    7. #7
      Ad absurdum Achievements:
      1 year registered 1000 Hall Points Made lots of Friends on DV Referrer Bronze Veteran First Class
      Spartiate's Avatar
      Join Date
      Jul 2007
      Gender
      Location
      Block 4500-7000
      Posts
      4,825
      Likes
      1113
      Can't see that eiher, and I meant numbers .

    8. #8
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      No numbers, I need to solve it for a general situation.

      Maybe if I don't embed the image: http://img139.imageshack.us/img139/5426/39764143va7.jpg

      I'll describe the pictures

      I have an angle between the particles (the normal to their touching surfaces), I can use it as either the angle or a normalized vector [dx, dy]

      The mass variables are m1 and m2

      The velocity is stored in vectors [vx, vy]. Of course I can go to angle and magnitude if I need to with Pythagorean theorem and inverse tangent.

      From that information I'm trying to figure out an algorithm to figure out the trajectory of the particles after the collision (preserving momentum) for a perfectly elastic collision and store them in a vector [tx, ty] for both particles.

      If I can do it all with vectors I'd be happy, but I doubt it. I can convert to magnitude + angle to [x, y] very easily.

    9. #9
      Member Achievements:
      1 year registered Veteran First Class 5000 Hall Points

      Join Date
      Sep 2004
      Gender
      Location
      Seattle, WA
      Posts
      2,503
      Likes
      217
      Image cannot be displayed because it contains errors.

    10. #10
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Maybe PCs can't do CYM colour, here's an RGB image.

    11. #11
      Ad absurdum Achievements:
      1 year registered 1000 Hall Points Made lots of Friends on DV Referrer Bronze Veteran First Class
      Spartiate's Avatar
      Join Date
      Jul 2007
      Gender
      Location
      Block 4500-7000
      Posts
      4,825
      Likes
      1113
      Hey, I can see that .

      It's a little different than anything I've worked with before, but I'll see if I can think of anything...

    12. #12
      Member Achievements:
      1 year registered Veteran First Class 5000 Hall Points

      Join Date
      Sep 2004
      Gender
      Location
      Seattle, WA
      Posts
      2,503
      Likes
      217
      http://en.wikipedia.org/wiki/Elastic_collision

      complete with animations and everything!

    13. #13
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Thanks for that, but Grrrrrr. My algorithm only works in one dimension. Please tell me what I'm doing wrong, I've spent two days on this trivial part of my program.

      It's GNU C. The structure of the particles should be obvious:
      x, y are position
      vx, vy are velocity along the axis

      Code:
      	//get the normal to the collision
      	float dx = spheres[p1].x - spheres[p2].x;
      	float dy = spheres[p1].y - spheres[p2].y;
      	float theta = atan2(dx, dy);
      	
      	//get the angle of the Velocities
      	float vangle1 = atan2(spheres[p1].vx, spheres[p1].vy);
      	float vangle2 = atan2(spheres[p2].vx, spheres[p2].vy);
      	
      	//rotate the angles into the normal to collision axis
      	vangle1 = vangle1 - theta;
      	vangle2 = vangle2 - theta;
      	
      	//Pull out the velocities' magnitude
      	float u1 = Velocity(p1);
      	float u2 = Velocity(p2);
      	
      	//change velocity vectors to new coordinate system
      	spheres[p1].vx = sinf(vangle1) * u1;
      	spheres[p1].vy = cosf(vangle1) * u1;
      	spheres[p2].vx = sinf(vangle2) * u2;
      	spheres[p2].vy = cosf(vangle2) * u2;
      	
      	//take out mass so the forumula is easier to read
      	float m1 = spheres[p1].mass;
      	float m2 = spheres[p2].mass;
      	
      	//handle velocities for the new x axis	
      	float v1 = (spheres[p1].vx * (m1 - m2) + (2 * m2 * spheres[p2].vx)) / (m1 + m2);
      	float v2 = (spheres[p2].vx * (m2 - m1) + (2 * m1 * spheres[p1].vx)) / (m1 + m2);
      	spheres[p1].vx = v1;
      	spheres[p2].vx = v2;
      	
      	//handle velocities for the new y axis
      	v1 = (spheres[p1].vy * (m1 - m2) + (2 * m2 * spheres[p2].vy)) / (m1 + m2);
      	v2 = (spheres[p2].vy * (m2 - m1) + (2 * m1 * spheres[p1].vy)) / (m1 + m2);
      	spheres[p1].vy = v1;
      	spheres[p2].vy = v2;
      	
      	//get the angle of the new Velocities (still in new coordinate system)
      	vangle1 = atan2(spheres[p1].vx, spheres[p1].vy);
      	vangle2 = atan2(spheres[p2].vx, spheres[p2].vy);
      	
      	//rotate back into x/y coordinate system
      	vangle1 = vangle1 + theta;
      	vangle2 = vangle2 + theta;
      	
      	//Pull out the velocities' magnitude from the collision coordinate system
      	u1 = Velocity(p1);
      	u2 = Velocity(p2);
      	
      	//change velocity vectors back to x/y coordinate system
      	spheres[p1].vx = sinf(vangle1) * u1;
      	spheres[p1].vy = cosf(vangle1) * u1;
      	spheres[p2].vx = sinf(vangle2) * u2;
      	spheres[p2].vy = cosf(vangle2) * u2;
      I know it's bad code I'm from the school of make it work, then make it fast
      Last edited by ninja9578; 03-16-2008 at 12:53 AM.

    14. #14
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      If I swap v1 and v2 for the second velocity calculation it works alright until I introduce two particles of different mass.
      Last edited by ninja9578; 03-16-2008 at 02:26 AM.

    15. #15
      Member Achievements:
      1 year registered Veteran First Class 5000 Hall Points

      Join Date
      Sep 2004
      Gender
      Location
      Seattle, WA
      Posts
      2,503
      Likes
      217
      You say it works in one dimension... is it just the X dimension? Does it work in just the Y dimension? Try getting them to work separately. It eliminates a whole lot of unknowns.

    16. #16
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      It works in any direction, x axis, y axis, arbitrary angle... it just only moves them apart parallel to velocities, if they are offset a little bit they should fly off at an angle to that, but don't.

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •