For a video game, I am trying to figure out whether the ship is headed to the right direction, that is, forward relative to the race direction as it's a racing game in 3 dimensions.
Basically, the game would show up a wrong way indicator when the ship is driving in the opposite direction.
This is pretty easy to achieve when there is only one path:
if dot product of 'track forward vector' and 'ship direction' is > 0
then ship is going forward
else ship is going backward
However, when there is a branch in the track, i.e. two possible paths, I realized it isn't as straightforward to figure it out.
I did try to take the maximum of dot products between 'ship/1st path' and 'ship/2nd path' and if it's positive then ship is going forward, however, that ended being not reliable at all depending where the ship actually is in the track.
Here are two pictures with explanations:
- the triangle is the ship, the tip being the direction
- track is made of sections that are made of quads (showing the floors of 3 of them)
- lines in middle of the road are from/to section centers (magenta indicating a junction)
After thinking, rough guess is that there should be the notion of a valid angle range.
Tried to represent this fact as a pie chart as can be seen below:
Can you suggest an approach on how this problem could be solved?

