matlab - How can you tell if a given point is inside a STereoLithography (.stl) file object c++ -



matlab - How can you tell if a given point is inside a STereoLithography (.stl) file object c++ -

i trying determine of point within polyhedron imported stereolithography (.stl) file. i'm wondering if there c++ solution/library in existence solves problem.

i'm looking avoid shelling matlab solution

the theory of problem simple, when go point outside have pass odd number of facings (triangles).

some pseudo code

vector3d tooutside { point, pointoutside }; // !!! how know point outside ?!? for_each(trianglelist, [&count, =tooutside](triangle& triangle) { if (intersect(triangle, tooutside) // fussiness edges , triangle points. ++count; } if (count %2 == 1) isinside = true; else isoutside = false;

finding point outside polyhedron, find highest x,y,z , add together 1.0 them.

pseudo prof [todo:link article more stiff prof] simple case box, if within box, there 1 intersection side if follow tooutside vector. if within polyhedron, if pass through triangle outside, if pass through 2 triangles more (in , out) can still tell inside. if in fact outside polyhedron pass through , number of triangles (or zero) when next tooutside vector.

a c++ implementation @ geometrictools under mathematics->containment->point-in-polyhedron->3d both .h , .inl files.

there might more optimized tests uses normal vector outside. if have multiple objects need test against, consider making bounding box each utilize culling, vector tests can expensive.

c++ matlab

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -