From: Joerg H. <jo...@lu...> - 2008-08-26 02:08:30
|
> Very interesting suggestion, I will definitely look into this =) How > does it behave, though, if one kart is at the end of lap 2 and the kart > in front is at the beginning of lap 3? Should work itself out: assume a track length of 500, the kart on 2nd lap a DistanceDownTrack of 480, the one on lap 3 a DistanceDownTrack of 20: --> distance = 20-480 = -460 --> negative, so distance += 500 = 40, which is the value you want to have. If the positions of the karts are reversed, the distance will be 480 - 20 = 460 - and I'd say that it's unlikely that there isn't another kart closer by :) Same without wrapping around: kart A at 20, kart B at 40 --> B will have a distance of 20 to kart A, --> A will have a distance of 480 to kart B That should be (I hope) in all cases be the correct answer for you to find the closest kart. Cheers, Joerg |