[ODE] Bug in convex.cpp IsPointInPolygon()

Andres James andres.james+ode at gmail.com
Fri Jul 21 14:34:48 MST 2006

The loop in IsPointInPolygon doesn't index into the polygon array
correctly when i=pointcount-2 or i=pointcount-1. Here's my fix,
alternatively you could modify the two "%pointcount" expressions.

Index: convex.cpp
--- convex.cpp	(revision 1026)
+++ convex.cpp	(working copy)
@@ -283,7 +283,8 @@
   dReal d3;
   dReal d4;
   dReal vc;
-  for(size_t i=1;i<=pointcount;++i)
+  polygon++; // skip past pointcount
+  for(size_t i=0;i<pointcount;++i)
       dMULTIPLY0_331 (a,convex->final_posr->R,&convex->points[(polygon[i]*3)]);

More information about the ODE mailing list