Results 1 to 2 of 2

Thread: 2 spheres with mass collide

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    2 spheres with mass collide

    Just had a funny idea today to start making a small demo with lots of different mass and size circles. Just moving and bounding from eachother. It just turned out to be little difficult to think of... Went to MsPaint and sketched eventually this:


    I read about physics loop that can be set running loops as much as frame time milliseconds allow, and that should fix problem that comes with balls colliding to walls and eachother, making chainreactions. For example 60 fps gives
    1000ms/60-RenderingTime time for physics, preferrably reduce that a little more for more fluent application.

    I hope i didn't make a mistake somewhere, and if not, it may be helpful to someone someday. So as far as the collision part is just in theory level, i'll try and finish that demo in any unknown hour/day in the future

    edit: Attachment reduced the image blurry, had to use Tinypic...

    I guess i could try make a small summary too (sphere1 is the small, sphere2 is bigger on right):
    Final movement vector for sphere1 = Normalize(Sphere1.Pos-Sphere2.Pos)*MoveSpeed2*MassMult2 + movement1*MassMult1 + ReflectVector1*MoveSpeed1*MassMult2

    And cool thing about vectors is that they work exactly same way 2D and 3D with hardly any modifications.

    Edit2: Sample source and executable of demo included, it works even with gravity!

    No.. the bigger the mass of sphere the more it tends to slow down in my tests. With no gravitation and slowdowns, the application comes to almost standstill mode in some time. Also the small spheres seem to push big ones a bit, which could be caused of non-perfect collision detection and their movement. This reflection formula still holds as far as i can see. Although i haven't calculated if the total force remains same after collision, it is basic thing in physics.
    Attached Files Attached Files
    Last edited by User137; 27-01-2011 at 08:36 PM.

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
  •