My strategy was to apply the Bourke function for each segment of the polygon and then to return the smallest of those results as the answer. But something is going wrong.
Never mind. I figured it out. Went back and based my implementation on Bourke’s java example rather than the c example and I got it working. Here’s the code:
Gah! Seeing it now in the header on GH. Oh, well. At least I learned something about Bourke’s algorithm
Any particular reason that there’s nothing about ofPolyline on http://openframeworks.cc/documentation? Also, I came across ofInsidePoly() in the course of this adventure, which takes a vector of points rather than an ofPolyline. And now looking at ofPolyline it doesn’t look like it has an equivalent function so I’d need to store the points of my polygon both as a vector of ofPoints and as an ofPolyline, eh?
PS. I’d love to pitch in on improving the documentation in some way. Anything I can do to help? James and I are working on a thing to make it easier to find addons. Hopefully we’ll have something to show soon.
regarding documentation, there’s at least three threads on the development subforum about this. i think what needs to happen is someone/people need to be propose a solution, be told that their solution will be incorporated into the website/download so they know they’re not wasting their time, and then do it in one pass… but we’ll see what happens.
So, since I’m familiar with it at this point, I started working on trying to create a patch that would solve that issue. I made the changes in my own local copy of OF at first so that I could get it to compile with the re-written version of the code I was asking about here. I made the changes Math.h/Math.cpp and ofPolyline.h/ofPolyine.cpp. Everything compiles but I’m getting a linker error:
Undefined symbols for architecture i386:
“ofPolyline::inside(ofVec3f const&, ofPolyline const&)”, referenced from:
testApp::draw() in testApp.o
d: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
(ofPolyline::indside() is the new static method I added to ofPolyline with the updated guts of the former ofInsidePolygon().)
I tried cleaning both my app and OF as targets as well as deleting the .a file from openFrameworksCompiled/lib/osx/
I’m sure it’s something simple I’m missing to get this to compile and then I can test and move my changes into a real fork of the OF code base and issue a pull request all proper like. I’ve done an hour of googling now though without any luck in getting past this linker error. Any suggestions?