Quote: "A couple of months ago Philip "
(Stops nibbling on a jam sandwich)
Hark! Do I hear my immortal name mention'd?
Quote: "posted a bunch of code regarding autonomous steering behaviors "
It is me! This is the droid, er I mean bear, that you are looking for. Take me to your leader.
Quote: "Basically, I want to know when the two lines are closest to each other, so that the vehicles in question can manuver away from the point of potential collision. (this is in 3d, btw, not 2d, as the image suggests)
"
Mathematically speaking, there are quite a few ways to do this. A quick hack way would be to treat one of the two movement vectors, such as the red line in your picture, as a plane, with the normal vector that describes the plane pointing towards the current position of the other object, namely green ship. Treat the green ship movement vector as being a vector and do a vector / plane collision test. Take the position at which the green vector hits the plane and then do a distance between point and red vector test. Then check if that distance is within the radius of the spheres.
Thats one idea.
If you want to go for a less bodged effort, you'll need to do a dynamic test. What I would suggest is that you treat both red and green objects as moving spheres. The usual approach is then to assume one sphere is stationary and to test against the movement of the other. The equation is then:
t = e dot d - sqrt( (e dot d)2 + radius2 - e dot e)
where
t is the time when intersection occurs
e is the vector described by position of stationary sphere minus the position of the moving sphere
d is the normalised vector describing the DIFFERENCE of the two movement vectors of the two spheres (moving sphere vector minus stationary sphere vector)
the 2s are supposed to be squareds
radius is the combined radius of the two spheres
Note:
if the value inside the sqrt is negative, there is no intersection
If you want to know how this works (and check my math), its worth doing a few google searches. Or look at page 289 and page 290 of Fletcher Dunn and Ian Parberry's 3d Math Primer for Graphics and Game Development
Cheer if you like bears! Cheer if you like jam sandwiches!
"I highly recommend Philip" (Philip)