Talk:IsPointInPolygon2D
Very nice, would be superb if the creator could put it under the geometric library, but I am not putting anyone under pressure to do so. Just would be better in my honest opinion if all these useful functions would be put under a general heading instead of splattered into their own pages. --Nexii Malthus 16:11, 18 August 2008 (PDT)
- It can be included but not until it has been properly attributed and the license fulfilled. It is an illegal (since the licensing restriction were ignored) port of PNPOLY. I've written a new port from the original C code, I just haven't tested it yet. -- Strife (talk|contribs) 13:37, 19 August 2008 (PDT)
<lsl>//Copyright (c) 1970-2003, Wm. Randolph Franklin //Copyright (c) 2008, Strife Onizuka (porting to LSL) // //Permission is hereby granted, free of charge, to any person obtaining a copy //of this software and associated documentation files (the "Software"), to deal //in the Software without restriction, including without limitation the rights //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell //copies of the Software, and to permit persons to whom the Software is //furnished to do so, subject to the following conditions: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimers. // 2. Redistributions in binary form must reproduce the above copyright // notice in the documentation and/or other materials provided with the // distribution. // 3. The name of W. Randolph Franklin may not be used to endorse or promote // products derived from this Software without specific prior written // permission.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE //SOFTWARE.
integer isPointInPolygon2D(list vertx, list verty, float testx, float testy) {//Copyright (c) 1970-2003, Wm. Randolph Franklin; 2008, Strife Onizuka
integer i = ~(polygon != []); integer c = 0; if(i < -2) { float vxi = llList2Float(vertx, -1); float vyi = llList2Float(verty, -1); float vyj; do{ float vxj = vxi; vxi = llList2Float(vertx, i); if(((vyi = llList2Float(verty, i)) > testy) ^ ((vyj = vyi) > testy)) { if(vyj != vyi) c = c ^ (testx < (((vxj - vxi) * (testy - vyi) / (vyj - vyi)) + vxi)); else//working around lack of infinity in LSL c = c ^ (0 < ((vxj-vxi) * (testy-vyi))); } }while (++i); } return c;
}
integer isPointInPolygon2D(list vert, vector test) {//Copyright (c) 1970-2003, Wm. Randolph Franklin; 2008, Strife Onizuka
integer i = ~(polygon != []); integer c = 0; if(i < -2) { vector vi = llList2Vector(vert, -1); do { vector vj = vi; vi = llList2Vector(vert, i); if((vi.y > test.y) ^ (vj.y > test.y)) { if(vj.y != vi.y) c = c ^ (test.x < (((vj.x - vi.x) * (test.y - vi.y) / (vj.y - vi.y)) + vi.x)); else//working around lack of infinity in LSL c = c ^ (0 < ((vj.x-vi.x) * (test.y-vi.y))); } } while (++i); } return c;
}</lsl>
- Ok, coo, added isPointInPolygon2D( list vert, vector test ) into Geometric library as well as a isLineSegIntersectingPolygon2D function from softsurfer.com, added a new section for polygons and one for handling licenses effectively. Finally, added a small note in left bottom corner wether geometric function is 2D or 3D based for ease. --Nexii Malthus 06:53, 11 December 2008 (UTC)