Results 1 to 3 of 3

Thread: OpenGL objects with real world collision physics

  1. #1
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    OpenGL objects with real world collision physics

    I think this should be simple to do; I want to have spheres bouncing around in a cube.
    When a sphere hits another sphere I want both to be changes based on the angle of the collision, currently speed of the object is not important, though maybe need force or mass of object.
    All spheres will have same velocity and mass, it that helps make the equation simpler.


    To setup each object was thinking of the following:

    v1[3] = current vector of object.
    v2[3] = current vector of travel.

    optional varaibles:
    f = force
    m = mass
    s = speed

    I don't have a physics book handy, how would I find the resulting vectors for each object after a collision?

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2002
    Posts
    189

    Re: OpenGL objects with real world collision physics

    Sorry to say I can't help you with the physics and I'm sure you already knew this but for the collision detection use the distance formula.

  3. #3
    Member Newbie
    Join Date
    Jun 2002
    Posts
    33

    Re: OpenGL objects with real world collision physics

    I have thought a bit about this and so I now have the answer. The way to work it out is two apply energy conservation and momentum conservation. i.e. with u - init vel and v -final vel

    momentum: m1u1+m2u2 = m1v1+m2v2
    energy : m1(u1)^2 + m2(u2)^2 =m1(v1)^2 + m2(v2)^2

    just rearrange and sub one into the other.

    I will assume that m is the same for all spheres. This simply gives that v1=u1 and v2=u2 i.e. they just exchange velocities.

    Now its slightly more complicated because this is only in the direction of the centers. So first we must work out the vector representing the distance between the centres of the spheres:
    r=r2-r1 : r1-pos of sphere 1 and r2 pos of sphere2
    now make it a unit vector r/mag(r)
    now find the velocity in the r direction using the dot product. r . v gives the correct velocities. The easiest way to change the velocity is to do:

    u1=-r.u1 + r.u2

    And that should about do you. Hope that helps,

    fringe

    P.S. not sure if it is right I am just working it out now and have never tries it

Similar Threads

  1. Mapping the real world into OpenGL coordinates
    By melatonin in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 06-01-2013, 04:08 AM
  2. 3D projection of real world coordinates
    By Milo221 in forum OpenGL: Basic Coding
    Replies: 14
    Last Post: 11-29-2011, 03:38 AM
  3. HL2 models in the real world
    By V-man in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 05-29-2005, 01:14 AM
  4. materials in real world look
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-18-2000, 07:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean