0

enter image description here

I know this topic is known - Continuous Collision Detection

I have 2 Spheres that I have to find intersection between them as shown in the image.

the equations refer to the upper draw and I need to find the minimal t and then check something about the distance. I have no idea what these equations mean.

  1. what is each variable? I guess p10 and p20 are the first positions and v1 \ v2 are the direction vectors.

  2. no acceleration, no mass..

  3. the equations refer to 2 spheres that move. if ONLY ONE sphere moves, the equations solve it too because then, the velocity of 1 sphere will be zero.

  4. so how do I have to solve the equations? to find the minimal t that....?

thanks a lot!

user1118321
  • 25,567
  • 4
  • 55
  • 86
Alon Shmiel
  • 6,753
  • 23
  • 90
  • 138
  • 2
    Those equation don't find general collisions for you. They tell you where the balls move (in the absence of collisions). If you know (or suspect) that they have collided during a time interval then you can [find the collisions point](http://stackoverflow.com/questions/3692532/calcuate-x-y-point-that-2-moving-balls-will-collide) a number of different ways. So, how can you know when they have collided? Or failing that know most of the time when the definitely have *not* collided? – dmckee --- ex-moderator kitten Jun 03 '13 at 17:42
  • 1
    I'd start calculating the position of the quadrangle in the center of X on the picture, then calc the time then individual balls are there. This can show many no-coll cases. For the rest it's possible to refine with more precision, if needed – Balog Pal Jun 03 '13 at 17:48
  • 3
    1) Come up with a function that expresses the distance d(t) between the two balls as a function of time. 2) Solve for d(t) == 0. – Matt Phillips Jun 03 '13 at 18:02
  • thank you all, I'll try and if I don't succeed I'll ask more. thanks!! – Alon Shmiel Jun 03 '13 at 18:22
  • @MattPhillips Er... solve for `d(t) = \pm (r_1 + r_2)`. – dmckee --- ex-moderator kitten Jun 03 '13 at 19:27
  • @dmckee I don't quite get what the variables in your equation are supposed to be but if the idea is that what I said reduces rather trivially to just solving `p_10 + v_1(t) = p_20 + v_2(t)` for t, then ... yes. OP: Once you get t in this way, you can just plug it in to get the position. – Matt Phillips Jun 03 '13 at 19:33
  • @MattPhillips These are extended object, not points. You get a collision when the *surfaces* touch. Now, `\pm` is latex for plus/minus and the `_` indicates a subscript. If the circles have radii `r_1` and `r_2` the collision happens when `|d(t)|` first falls to `r_1 + r_2`. – dmckee --- ex-moderator kitten Jun 03 '13 at 19:40
  • @dmckee From OP's description it's not at all clear that his program is required to take the radii of the balls into account. But yes, if it does then that has to be accounted for. – Matt Phillips Jun 03 '13 at 20:57

1 Answers1

2

This is probably a question for StackExchange Mathematics. But here's my answer: The two equations tell you where the centers P_1 and P_2 of the circles or balls are at some point in time t are. Now you need to find a value for t for which the distance between P_1 and P_2 is the sum of the radii which I will call d (like distance). According the the theorem of Pythagoras the square of the distance of the two points is the sum of the squares of the coordinate differences. This square of the distance is a quadratic polynomial in t, i.e. a*t*t+b*t+c. Now you can find the value of t where the two balls or circles collide by setting this equal to d*d and solving for t. If there is no solution, then the balls/circles won't collide.

Ralph Tandetzky
  • 22,780
  • 11
  • 73
  • 120