Just the ones that go to the right of the vertex. We can test the two rays out of the vertex and see which of them go rightwards, and adjust the count accordingly. To understand the ideas behind the algorithm, I'd stick with the pseudo-code I started with in the previous section. A convex polygon is just one without any indentations. It can also be defined formally as having the property that any two points inside the polygon can be connected by a line segment that doesn't cross the polygons.
Convex polygons are typically much easier to deal with than non-convex ones.
These two points divide the polygon into two parts, the upper chain and the lower chain . Any line or ray crosses the polygon at most twice, and any vertical line or ray crosses each chain at most once. Just search for x in the first coordinates of points in the two chains. I'll describe an algorithm for finding convex hulls known as the Graham scan . The algorithm is easier to describe in terms of the upper and lower chains defined earlier.