Car Ahead Other

Sorry for stupid question , but i googled about but i cannot find a usable solution :
Knowing the position and direction of 2 cars, how do I calculate which one is ahead or on the right?
Thanks e sorry for english.
Carlo

There are a various ways of approaching this problem.

A simple way of solving this issue would be taking both positions of the vehicle and seeing its position relative to the track. For example on a 2D plane if the track was a simple round track of (x-4)^2 + (y-3)^2 = 25 then we would know depending on which lap the vehicle is in, assuming they are racing in a clock wise direction, that if car is at (9,3) and the second car is at (4, 8) we could be able to tell that in a clock wise rotation and lap value that the last value to appear when rotating will be the vehicle in the lead. All you would have to do is apply that knowledge (which was taught in Algebra) to a 3d plane (unless the Y axis must be taken into consideration if you are racing in like a spiral mountain or something) where the track coordinates will be compared to all the cars relative to their positions which will give you the exact position of every vehicle in order.

Hoped this helped.