I have a Car1 traveling (not directly) towards another Car2, both cars can freely drive away from each other (making the velocity from Car1 to Car2 negative)
What I know of the cars is the velocity, location (Vectors) and their distance in a 3d space.
Both Cars are not traveling at a constant speed, nor in a fixed position (straight line), Car2 could stop. This would obviously result in Car1 approaching Car2 at the velocity of Car1.
What I'm having trouble figuring out is how fast is Car1 approaching Car2?
Would anyone have an ideas where to start, or some formula?
I managed to figure this out in due time, I just had to calculate the relative velocity for Car1, by subtracting Car2's velocity from Car1's velocity and get the magnitude from that. I then got the distance from them and from a very small time interval I checked if they are going apart or not.
It's not a perfect system, and the formulas are not hard to figure out, I only have code snippets for it. But it works.