As part of a larger algorithm, I am traversing a set of interconnected line segments. On arriving at any vertex via a line segment, I need to find the leftmost line segment leaving from that point.
As an example, suppose I start at vertex A and follow line segment AB to arrive at vertex B, I now need to choose the leftmost of line segments BC, BD, BE... to arrive at the next vertex.
I can do this by taking the signed areas of each pair of exiting segments. If signed area of triangle BDC is positive, then BDC is counter-clockwise oriented so BC falls to the left of BD. I could then compare BC with BE and proceed likewise with other segments to find the leftmost exit. But this only works when angle CBD is acute. I will have to add a special case to handle obtuse CBD.
There must be a simpler way to do this. Any ideas?