2
\$\begingroup\$

I have the 2D positions and 2D velocity vectors of two objects. How do I calculate the closing velocity ? I want to get the closing speed.

Think of one jet tracks another jet with radar and you want to yield the closing speed, which is actually the distance-change / unit. (In this example Δmiles/h)

\$\endgroup\$
5
  • \$\begingroup\$ Velocity1 + Velocity2 \$\endgroup\$
    – jgallant
    Mar 13, 2016 at 14:32
  • \$\begingroup\$ Please clarify something: What do you mean exactly by closing speed? My guess would be that you want to get the speed of the distance-change between those two objects. Is that correct? \$\endgroup\$
    – LukeG
    Mar 14, 2016 at 14:18
  • \$\begingroup\$ @LukeG correct. Think of one jet tracks another jet with radar and you want to yield the closing speed, which is actually the distance-change / unit. (In this example Δmiles/h) \$\endgroup\$
    – Marco
    Mar 14, 2016 at 17:51
  • \$\begingroup\$ Thank you. Under that circumstances Samed's answer is indeed incomplete. It only yields correct results if the two jets would collide at some point with the current velocities. For a complete, general solution, please refer to my answer, which I tested for correctness. \$\endgroup\$
    – LukeG
    Mar 14, 2016 at 18:02
  • \$\begingroup\$ @LukeG Check my edited answer, I'm not sure if I do something wrong but, as you can see my formula still works even if objects don't collide. \$\endgroup\$ Mar 14, 2016 at 21:06

3 Answers 3

6
\$\begingroup\$

You essentially have two lines with the equations:
\$a(t)=a_0 + t*v_a\$

\$b(t)=b_0 + t*v_b\$

where \$a_0, b_0, v_a, v_b\$ are vectors with the same dimension and unit (meters for \$a_0\$ and \$b_0\$ and meters per second for \$v_a\$ and \$v_b\$).

\$a(t)\$ and \$b(t)\$ are the positions of your objects at time \$t\$ (in seconds if using the units above).

Distance over time is calculated by subtracting the positions and taking the length of the vector:
\$d(t)=\left|a(t)-b(t)\right|=\left|a_0-b_0+t*(v_a-v_b)\right|\$

This has to be differentiated to get the closing speed (The multiplication used is the dot-product): \$c(t)=d'(t)=\frac{(v_a-v_b)*((v_a-vb)*t+a_0-b_0)}{\left|(v_a-v_b)*t+a_0-b_0\right|}\$

The value of \$c(t)\$ is a scalar.

You probably want the closing speed at t = 0 (i.e. now), so it can be simplified further:

\$c(0)=d'(0)=\frac{(v_a-v_b)*(a_0-b_0)}{\left|a_0-b_0\right|}\$

Unit of the result is the same as the components of the original velocity vectors. It is negative if the objects get closer to each other and positive if the distance increases. If you want it the other way around you have to multiply by -1.

\$current closing speed=-c(0)=-\frac{(v_a-v_b)*(a_0-b_0)}{\left|a_0-b_0\right|}\$

Note that this works for all dimensions.

Every matrix-/vector-math library will support all of the necessary operations. Depending on its design this can be written as a single line of code. However you may prefer to store \$a_0 - b_0\$ in a temporary variable.

In Pseudocode this may look like this

val tmp = a.position - b.position
return -((a.velocity - b.velocity).dot(tmp)/tmp.length)
\$\endgroup\$
1
  • \$\begingroup\$ thx Luke for the detailed explaination \$\endgroup\$
    – Marco
    Mar 13, 2016 at 17:17
1
\$\begingroup\$

enter image description here

To find the relative velocity vector, you need to substract the vectors. The magnitude of that vector is your closing speed.

(Note that the operation inside the magnitude function of the third situation is a vectoral substraction, not a scalar one.)


Edit:

Assume initial positions are A and B, distance is dis, velocities are v(A) and v(B). enter image description here

(As you can see, objects can never collide.)

Now, if we do this:

enter image description here

As you can see now, the c vector is the relative velocity.

Now, we can write these equations:

enter image description here

Also these:

enter image description here

Now, here is what you want in question:

enter image description here

As we wrote above, this yields to this:

enter image description here

Which eventually yields to:

enter image description here

Which is our relative velocity.

\$\endgroup\$
11
  • \$\begingroup\$ I don't think this answer is correct. While it yields correct results for some basic cases it is definitely not correct for the general case, which, for my understanding, is what was asked here. The correct distant function is a hyperbola, which does not result in a constant closing speed, as your solution suggests. \$\endgroup\$
    – LukeG
    Mar 14, 2016 at 12:33
  • \$\begingroup\$ @LukeG The closing speed is the magnitude of relative velocity of the object which is moving away, relative to the closing object. Relative velocity is found by this formula: Object B's velocity relative to Object A = (Object B's velocity) - (Object A's velocity). (Remember that velocity is a vector, so you need to do vectoral substraction.) \$\endgroup\$ Mar 14, 2016 at 13:55
  • \$\begingroup\$ If the objects collide you are right and your solution works. But if they merely pass each other their distance does not change linear. In the general case, where the objects don't necessarily collides your solution is merely the asymptotic value of 'closingSpeed(t)'. \$\endgroup\$
    – LukeG
    Mar 14, 2016 at 14:07
  • \$\begingroup\$ @LukeG I think you assume objects have accelerations, the OP said he has the velocity vectors, but he didn't mention about acceleration. \$\endgroup\$ Mar 14, 2016 at 16:42
  • \$\begingroup\$ No, I did not take accelerations into account. Look at my answer where I derive the general formula in-depth using analytical methods. As I said, your formulas give correct results only if the objects collide. I made a excel sheet detailing this, I can upload it if you want to. \$\endgroup\$
    – LukeG
    Mar 14, 2016 at 16:55
-2
\$\begingroup\$

Simple: Unlike the rest of these answers.

V1*sin(dir) - V2*sin(dir)

30*sin(090) - 40*sin(270) = 70

If you want the range, just add it in like so

Range-(30*sin(090) - 40*sin(270) = 70)

\$\endgroup\$
3
  • \$\begingroup\$ It's completely unclear what you are trying to say. Please clarify what the variables/formulas are supposed to say. \$\endgroup\$
    – LukeG
    Apr 8, 2016 at 8:26
  • \$\begingroup\$ Sorry about that. I made a quick graph to show you exactly what I mean. desmos.com/calculator/shjlof82kq \$\endgroup\$ Apr 8, 2016 at 8:49
  • \$\begingroup\$ This is transparently incorrect. Let's choose angles so that the two objects are heading in opposite directions, 0 and 180, directly toward / away from one another. We'd expect the closing speed to be the sum of their speeds (positive or negative, depending on whether they're approaching or separating), but this formula will give a result of zero, claiming the distance between them is unchanging. \$\endgroup\$
    – DMGregory
    Dec 23, 2018 at 15:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .