I have some polyline data that represents a navigation route generated using Dijkstra's algorithm. Along this route I would like to calculate anytime a turn is required. Ideally, this would be some threshold where the route would require a turn greater than X amount.
Given a polyline, what are some techniques to calculate a turn and it's direction?
I am not using road data from anything like OSM. The data is custom captured coordinates for a traveled path. This means I can't use something that consumes road networks like from OSM data.
I am looking for mathematical techniques to calculate the turns in my custom data. For example, I am currently using two segments of my path. Point1 -> Point2 and then Point2 -> Point3. With these two vectors I am trying to determine if there is an angle in direction change that could be considered a "turn". I am not sure of all the variables I need to take into account here with heading/bearing, etc. Any explanation of what to consider would help.
- Converting the lat,long data into cartesian coordinate values
- Creating two vectors p1->p2 and p2->p3.
- Normalizing those vectors
- Taking the cross product of those vectors
- Cross product > 0 turn right, less than 0 turn left, otherwise straight.