Hi,
I need to solve a relatively simple thing -- I've got n-vertices convex 2D polygon and a horizontal (!) line with some 'y' coordinate. I need only one thing: to check if the polygon is crossed with this line (i.e. have 2 intersections) or not.
The fastest one I can think of is to find min/max y coordinates within a polygon (loop repeated n times with two compares and two stores) and then to compare if the min y <= y < max y.
Somehow I feel this could be solved more "mathematically" but I always end with slower code (for example vector way -- I need to compute differences for n[i] and n[i+1], then multiply them, add etc -- much slower then 2 cmps+stores).