My original notion for this was to process a list of points and not have to get or create any real objects. Kerry, your solution with the rays is interesting because it is essentially the same as my code where the ray is one half of my pntXs to pntXe test line. I could have tested a line from PNT to pntXs or pntXe and it would always be odd if the point was inside and even if the point was outside. But you would still come upon my current problem if your ray crossed a vertex.
Joe, I will give your code by Luis and John a good looking-at. Since ultimately when I use this function I will be getting the points by exploding a temporary copy of a REGION into lines and then erasing the lines, if your code will opperate on the region directly (edit: nevermind, it won't), it would be a better solution. The interesting thing about that function is that it almost behaves correctly when the curve is self-intersecting. I finds all of the insides but thinks that some of the nested outside are inside also. It's definatelly a keeper, though.
Take a covex, closed polyline with alot of points and hatch it with an associative hatch by selecting the object instead of picking a point. Then twist it up by moving the vertices around. The hatch will update and should always be valid by alternating inside/outside for any nested shapes. Joe's function finds most of these correctly.
I am still going to work on my quirky code above to have a nice library function that is universal. The method it uses is probably pretty standard, since it is in a book about computer graphics algorithms. So let me explain my ugly code a little bit:
The function asks for PNT as a point defined by a List of two or three Reals and lstPOINTS as a list of lists of two or three reals, kinda like the GetPolylinePoints function returns. It also asks for a FUZZ which is given to the Equal function as the fuzz factor.
The first for conditions determin if the point is outside the min-max bounding box in each direction and it also establishes dXmin and dxMax as the min and max X coordinates for my test line. d stands for Decimal and it lets me know that they are Reals. (I'm Hungarian so Hungarian Notation holds a special place in my heart, and it's very well suited for LiSP).
If none of those conditions are true then we go on to the step 2 as described in the book. I set up pntXs and pntXe as the start and end points of my test line. I will eventually re-write this to eliminate the Inters function and test the intsection of an infinite line with the segments, but that code is about half done. here I also add the first element in the list of points to the end of the list to make it a loop, so when I step through the length of the original list with the (Nth cnt ...) and (Nth (1+ cnt) ...) the last point will be the same as the fist to close the polygon.
Now I loop through the length of the original list (1- (Length ...)) and test every segment to see if it intersects my X test line. If it does I Cons it to lstTest. Then I strip out all of the x coordinates and arrange them in ascending order by MapCar-ing the Car function thru the list and giving it to VL-Sort.
The next portion where I strip the duplicates from the front and end of the list is a result of my BFI coding and should be ignored before it embarrasses me!
Next I make a list of pairs of points, lstPairs by Constructins a List of the Car and Cadr of the list and dropping the first two elements with Cddr and looping until the original list is nil. I only do this to make MapCar-ing through the list to test the pairs easier then looping the elements of the first list two at a time.
The list is backwards, so I reverse it. The list looks like this ((x1 x2) (x3 x4) ...). The next Cond determines the result.
If the Car of PNT Equals either the Car of one of the elements of lstPairs or the Cadr of one of the elements, then the test point is on the boundary of the polygon.
If the Car of PNT false between on of the pair so that x1 < xt > x2, than the point is on the inside.
Otherwise, the last T condition returns nil and the point is on the outside.