finding the min distance between two vectors
Im trying to find the minimum distance(sum of their radii) between two circles.
The circles have position vectors a radius and a velocity vector.
i can find the minimum(s) distance using Pythagoras and a loop. but this is costly i would much prefer to use some sort of differentiation.
a=sum of radii
think iv done it in one plane at least
e= sum of radii
e = (a+bt)-(c+dt)
e² = (a+bt)-(c+dt)* (a+bt)-(c+dt)
-2abt + 2ac + 2adt -a2 + 2bct + 2bdt2 -b2t2 -2cdt -c2 -d2t2 + e = 0
2bdt^2 - b2t^2 - d2t^2
-2abt + 2adt + 2bct – 2cdt
-a2 - c2 + 2ac+ e
(2ab- b² - d²)t²
-2t(ab + ad + bc - cd)
-a² - c² + 2ac + e
This looks like a quadratic since if we remove all known variables we get
t² - 2t +c
Therefore we can solve using the x = (-b +- root(b² -4ac))/2a
Let a=A (a, b, d) = (2ab- b² - d²)
Let b=B (a, b, c, d) = (2(ab + ad + bc – cd))
Let c=C (a, c, e) = -a² - c² + 2ac + e
solve this for each plane we need to consider and find the closest positive time to zero.