c++ - Geometry rounding problems: object no longer convex after simple transformations -
i'm making little app analyze geometry. in 1 part of program, use algorithm has have convex object input. luckily, objects convex, barely (see image).
after apply transformations, algorithm fails work (it produces "infinitely" long polygons, etc), , think because of rounding errors in image; top vertex in cylinder gets "pushed in" because of rounding errors (very exaggerated in image) , no longer convex.
so question is: know of method "slightly convexify" object? here's 1 method tried implement didn't seem work (or implemented wrong):
1. average vertices create vertex c inside convex shape. 2. let d[v] distance c vertex v. 3. scale each vertex v center c scale factor 1 / (1+d[v] * convexification_factor)
thanks!! have cgal , boost installed can use of library functions (and do).
you can make object convex computing convex hull of it. that'll "convexify" anything. if you're sure input has departed being convex, shouldn't problem.
cgal appears have implementation of 3d quickhull in it, first thing try. see http://doc.cgal.org/latest/convex_hull_3/ docs , example programs. (i'm not sufficiently familiar cgal want reproduce examples , claim they're correct.)
Comments
Post a Comment