Skip to content

Instantly share code, notes, and snippets.

@cipher982
Last active February 16, 2018 00:40
Show Gist options
  • Save cipher982/6a66ea74fc22d9f51183ce7f6a6e4721 to your computer and use it in GitHub Desktop.
Save cipher982/6a66ea74fc22d9f51183ce7f6a6e4721 to your computer and use it in GitHub Desktop.
// estimate longitudinal position of a car (s)
check_car_s += ((double)prev_size * 0.02 * check_speed);
if (car_lane == lane) // if the other car is in 'lane' (our lane)
{
// is it within 30m ahead of us?
car_ahead |= check_car_s > car_s && check_car_s - car_s < 30;
}
else if (car_lane - lane == -1) // if left of us
{
// 30m front or back?
car_left |= car_s - 30 < check_car_s && car_s + 30 > check_car_s;
}
else if (car_lane - lane == 1) // if right of us
{
// 30m front or back?
car_right |= car_s - 30 < check_car_s && car_s + 30 > check_car_s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment