algorithm - Find Leftmost Line Leaving a Vertex -


as part of larger algorithm, traversing set of interconnected line segments. on arriving @ vertex via line segment, need find leftmost line segment leaving point.

as example, suppose start @ vertex , follow line segment ab arrive @ vertex b, need choose leftmost of line segments bc, bd, be... arrive @ next vertex.

i can taking signed areas of each pair of exiting segments. if signed area of triangle bdc positive, bdc counter-clockwise oriented bc falls left of bd. compare bc , proceed likewise other segments find leftmost exit. works when angle cbd acute. have add special case handle obtuse cbd.

enter image description here

there must simpler way this. ideas?

consider line segments vectors. want choose leftmost of bc, bd, be, ... this, calculate counter-clockwise angle between ba (which ab in reverse direction) , other directed segments bc, bd, be, ..

the segment want 1 largest ccw angle.

to calculate ccw angle vector bx, use atan2() calculate orientation angles a , x ba , bx. ccw angle (2π+x-a) mod 2π. (i.e. normalized in interval [0,2π]).


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -