0
votes

I'm going to develop carom board game. I'm having the problem with the collision of two pieces. How to find the collision point of two pieces. And then how to find the angle and distance the pieces travel after collision.I found the solution of the collision point at circle-circle collision. here the solution is described with trigonometry, but I want the solution with vector math. With which the problem of the distance covered after collision will also be solve easily.

1
Read the answer all the way to the end. At the end, the trigonometry cancels out.Raymond Chen
It's fine, but for the distance travel after collision, we require the vector physics.Ahmed Ali
What are you looking for? You have a collision criterion. You have the point of collision, which is somewhere on the line between the two centre points of your objects. You have the normal on the tangential plane at the collision point, which is just the difference vector between collision point and centre point. It's all vector maths, no trigonometric functions involved.M Oehm
I'm voting to close this question as off-topic because it is a physics question, not a programming question. "Given two circular objects moving with these velocities and colliding at this point, what are their resulting positions after collision?" (Note that your question is underspecified. You do not know the momentum or elasticity or friction coefficient.) Once you get the answer from a physicist, if you have trouble converting it into a program, then you can ask here.Raymond Chen
If one circle is centered at A with radius a and the other is centered at B with radius b, and they are touching, the point of contact is A +(B -A)a/(a+b). Now, about the collision, do you know the masses and velocities of the pieces? Is there friction in the collision itself? I assume that the drag on a moving piece is constant, and proportional to the piece's mass; do you know the coefficient?Beta

1 Answers

1
votes

You do not need to find the collision point for the collision computation itself. To detect a collision event, you only need to compare the distance of the centers go the sum of radii

sqrt(sqr(x2-x1)+sqr(y2-y1))<=r1+r2

or

dx*dx+dy*dy <= (r1+r2)*(r1+r2)

where (x1,y1) and (x2,y2) are the positions of disks 1 (with mass m1, radius r1 and velocity (vx1,vy1)) and 2. Differences are always 2 minus 1, dx=x2-x1 etc.


You will almost never get that the collision happens at the sample time of the time discretisation. With the above formula, the circles already have overlap. Depending on time step and general velocities this may be negligible or can result in severe over-shooting. The following simple computation assumes slow motion, i.e., very small overlap during the last time step.


The only thing that happens in the fully elastic collision of non-rotating disks is a change in velocity. This change has to happen only once, when further movement would further reduce the distance, i.e., if

dx*dvx+dy*dvy < 0

where dvx=vx2-vx1 etc.

Using these ideas, the computation looks like this (see https://stackoverflow.com/a/23193044/3088138 for details)

dx = x2-x1; dy = y2-y1;
dist2 = dx*dx + dy*dy;
R = r1+r2;

if ( dist2 <= R*R )
{
    dvx=vx2-vx1; dvy=vy2-vy1;
    dot = dx*dvx + dy*dvy;

    if ( dot < 0 )
    {
        factor = 2/(m1+m2)*dot/dist2;
        vx1 += m2*factor*dx;
        vy1 += m2*factor*dy;
        vx2 -= m1*factor*dx;
        vy2 -= m1*factor*dy;
    }
}