COLLISION DETECTION

Importance

Why is collision detection slow?

Explosive Growth

Using the formula: Number of collision tests = (n² -n)/2

Objects                Collision Tests
  2                          1
  3                          3
  4                          6
  .                          .
  .                          .
  .                          .
 20                          190

O(n²)

Eliminating Collision Tests

  • Collision Testing To find more detailed information on these just click here.



    Two collision-detection algorithms that we are going to discuss




    I-COLLIDE- An incremental algorithm for collision detection between solid models.

    Two objects are very close if their axis aligned bounding boxes overlap.

    What are bounding boxes?


    Sweep and Prune




    This page is created by Murat Gorguner

    IMPULSED BASED SIMULATION

    The two fundamental requirements you want in dynamic simulation:

    Impulsed based simulation attempts to fulfill these two requirements

    Constraint based vs. impulsed based simulation

    dealing with contact

    In constraint based simulation:

    Example - ball rolling along a table top

    In impulsed based simulation

    Example - ball resting on table top

    Procedure for implementing impulsed based simulation

    First, you assume objects travel in ballistic trajectories when not colliding with anything

    For each object, a bounding box is created to enclose the path of an object over a time interval, this is done at the beginning of each frame -a good interval is the frame rate =3D 1/30 seconds

    Intersections between the boxes are found, calculated to take O(n(1 + log R)) time where R is ratio of largest to smallest box size

    If two boxes don't intersect, objects won't collide in the next frame so no distance or time of impact calcuations have to be done

    If they do, the Lin-Canny closest features algorithm is used - same one as in I_COLLIDE -the shortest possible time to collision is calclulated

    Each pair is inserted in a heap sorted by time of collision, e.g. pair that= =20 will collide first will be at the top

    Time step is inceremented until the time of collision of the top pair

    L in-Canny algorithm is done again to find distance between the two objects - collision when distance falls below an epsilon which is at least 3 orders of magnitude smaller than the dimensions of the objects

    Drawbacks to this detection system:

    Since ballistic trajectory is assumed you can't have any forces all of a=20 sudden affect an =09 object's trajectory - no user interface possible after the initial forces

    This is OK for a pool game but not for most other games

    Solution:=7F Calculate bounding box that will encompass the maximum displacement an=20 object =09 can go over the time interval

    Consequences: More collision detection needed since boxes may be bigger and a it's=20 possible most =09 of the intersecting volumes will produce no collisions when thought was=20 expected =09 since the position of the object in the box varies on the forces enacted

    But User Interaction can happen!

    Computing collision impulses

    When two bodies collide, an impulse must be applied to a body so there is no= =20 interpenetration; the impulse applied to the other body is the negative of the impulse

    Once impulse is knowm, you can compute the linear velocity for center of=20 mass and angular velocity and algorith can continune

    You don't want to assume frictionless collisions or perfectly elastic=20 collisions, we want to model the real world, unless you're in space

    3 assumptions for collisions:

    1) Infinitesimal collision time

    - The duration of a collision is= =20 negligible compared to the time over which simulated objects move.

    Therefore

    a)the configurations of two objects may be taken as constant over the= =20 entire collision - even in simulations, it's just overkill to calculate the deformity and=20 rebounding of an object during a collision

    b)the effect of one object on another can be described as an impulse which= =20 gives rise to instantaneous change in linear and angular velocities of an object

    2) Poisson's hypothesis

    P_total =3D (1 + e) * P_max_compression

    e =3D constant between 0 and 1, dependent on object's material, called= =20 coefficient of restitution

    P_total =3D magnitude of normal component of the impulse done by one=20 object onto the other overthe entire collision

    =09 P_max =3D magnitude of normal component of the impulse done by one object= onto the other up to the point of maximum compression

    if e =3D 1, collision is totally elastic

    if e =3D 0, collision is totally plastic, objects stick together afer= collision

    P_max_compression is easy to characterize, it's the point at which the= normal component of the relative contact velocity vanishes.

    3)Coulomb friction

    u =3D contact velocity of object 1 realtive to object 2

    u_t =3D tangential component of u

    u_^t =3D unit vector in direction of u_t

    f_n =3D normal component of force exerted by object 2 on object= 1

    f_t =3D tangentialcomponent of force exerted by object 2 on= object 1

    m =3D coefficient of friction

    if u_t !=3D 0 ----> f_t =3D -m * abs(f_n) * u_^t

    if u_t =3D 0c ----> abs(f_t) <=3D m * abs(f_n)