PDA

View Full Version : Whats algorithm calculate difference between cars?



Mucilon
28-02-2016, 05:08
I have working in new aplication using project cars, but i have a great problem, can't calculate diference between cars. Someone have a idea?

MikeyTT
28-02-2016, 11:57
By difference do you mean time gap?

If so there are two variables that give you this. Without looking it's something like splittimeahead and splittimebehind. For the other racers, we don't get the timing data, so not that easy to do.

Mucilon
28-02-2016, 17:39
I have average speed, total distance, and current lap time for all pilots.

gap = (totaldistanceP1 - totaldistanceP2) / ?

I tried use

avgSpeedP1 - avgSpeedP2 not work

(avgSpeedP1 - avgSpeedP2)/2 not work



any idea that work?

FR-Alan
29-02-2016, 11:45
v (m/sec) = d (m) / t (sec) -> t (sec) =d/v.
You should have the gap doing : [d/v]P1 - [d/v]P2.
Question could be, how to know who is P1 ? P1 could be the one with the highest distance form the start to now (Cumul of passed lap distance + distance on the current lap) and so on for P2, P3 etc...
Not sure about everything but i will have been going for that to try.

Mucilon
29-02-2016, 13:14
I made in some test and have some numbers, for P1 1131m and 15,93 m/s for P2 836m and 11,77m/s, in the game the gap is 8.893,
using the laws of most common physical did not get satisfactory results. and now?

MikeyTT
29-02-2016, 17:32
Are you not over complicating things with the m/s calculation?

If P1 is 38 seconds into lap 2 and P2 is 31 seconds into lap 2, then you know that the gap is 7 secs. The complexity is if you're not on the same lap. You must be running a separate timing variable that's calculating the lap time for all the players, so use this as a constant when you're working out the gaps.

If you only want gaps when you run a sector, which is common, then you know what the sector transition from S1 to S2 would be for P1. Log this time and then every other player that hits the S1/S2 point you can calculate the gap. Same thing for the other sector transitions then. Alternatively if you want more fidelity then do this for certain track distance points (every 20mtrs or so). You'd end up with a dictionary of distances and time @ that point for each player. Simple enough to work out the gaps between any player then.