In-Polyhedron Test
Filed under: CAD, Computational Geometry, Graphics
13 Comments
Popularity: 12% [?]
Related Posts
Comments
13 Comments on In-Polyhedron Test
-
tolga on
Fri, 16th Oct 2009 19:23
-
Ajay on
Mon, 29th Mar 2010 20:35
-
María Herrojo Ruiz on
Tue, 6th Apr 2010 15:27
-
María Herrojo Ruiz on
Tue, 6th Apr 2010 21:15
-
Denis Lisin on
Fri, 30th Jul 2010 16:44
-
Denis Lisin on
Tue, 3rd Aug 2010 00:53
-
Cam Straatsma on
Sun, 15th Aug 2010 05:09
hello.. this looks like a quite useful code…
but there is a problem i cannot figure out.
i have the parameters for a surface : triangles, points and normals.
my problem starts here: the normals are not normals for triangles but they are normals at the points.
however your function requires the normals for triangles. Is there a way to estimate the normals for triangles from the normals of the points, so that I can use your function?
i will be so glad to hear your any possible solution for this.
thank you in advance.
[Reply]
Hi Luigi,
I tried to use this algorithm to find points in a non convex shape and I get some extra points that lie outside the shape. I checked the normal of the facets and they seem to be ok (outward pointing). I have uploaded a screen shot of the points overlapped on the triangulated surface (points.bmp) and also an xls file (data.xls) which contains the vertices (columns A:C) and faces (columns E:G) in the following link. If you could take a look and give your comments that would be great.
http://people.clarkson.edu/~sonarav/
Thanks,
Ajay
[Reply]
Luigi Giaccari Reply:
March 30th, 2010 at 12:54
That’s a numerical problem that comes form the presence of almost vertical facets.
Run the algorithm this way and it should be ok:
in1=InPolyedron_v3(p,t,tnorm,qp); id=[3 2 1]; in2=InPolyedron_v3(p(:,id),t,tnorm(:,id),qp(:,id)); id=[1 3 2]; in3=InPolyedron_v3(p(:,id),t,tnorm(:,id),qp(:,id)); in=in1&in2&in3;
Luigi
[Reply]
Hi Luigi,
your code seems really nice. It works good with your examples. I would like to test it with some data I have from a brain structure (subthalamic nucleus) and with some empirical (query) points of the electrodes implanted (inside/outside would be the question).
My problem is the following:
I have the coordinates of the set of 3 points constituting each triangle:
polyedron size [329x9] (3 points x 3D: 329 triangles).
Because the original data, ist vtk, it also gives me the following triangles indices:
triangles indices [1974x3]
The problem is that, actually, I don’t know where the triangles indices come from, since they are already given in the original data.
The indices [1974x3] I have seem not to work for trisurf, when I give the data points of the polyedron as [987x3]. MATLAB says “Faces values must be >= 1.0″.
So, in order to test your method, do you have a suggestion to recompute from the original set of 3 points for each triangle the correct triangle indexes for your method?
Given “p”, how do you compute “t”(tringle indices) and “tnorm”?
Regarding the normal vectors to each triangle. It is easy to compute the normal to each triangle (cross product of two vectors constititung the triangle, then checking for the outward direction) and locating it, e.g. at the middle of the triangle or at any of its points. The I would have 1 normal vector for the surface of each triangle, right? Or do I need 3 normal vectors at each point of the triangle for your method?
How comes that your “tnorm” has the same size as “t” (triangle indices) and not as the surface points “p”?
Hope you have a tip.
I’m really looking forward to testing your method with my data!!
Cheers,
María
[Reply]
I got it.
Now everything works fine.
Great! Thanks for writing Inpolyedron. It is really fast!
Cheers.
María
[Reply]
Thanks for the code, works fine.
Important issue for me is it considers the points on boundary as inner points.
[Reply]
Luigi Giaccari Reply:
August 2nd, 2010 at 10:04
Be careful with boundary points, numerical accuracy can be very painful!
[Reply]
Well, I implementing some combination of so-called meshless methods, so the pain with boundary points here isn’t so strong as usual. Actually i need your (great) function exclusively to visualize results.
[Reply]
Hi Luigi,
I was just wondering how you generated the input data for the test geometries included with the function (i.e. the SphereSurface.mat, StubAxleSurface.mat, etc. files). Do you draw them in a CAD program and then use a triangular meshing algorithm?
Thanks,
Cam
[Reply]
Luigi Giaccari Reply:
August 17th, 2010 at 18:32
The input data can be retried from an stl file generated from whatever CAD system.
To transalte it in matlab format you can use:
http://www.advancedmcode.org/stl_import-import-function-for-stl-files.html
[Reply]
Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!
Include MATLAB code in your comment by doing the following:
<pre lang="MATLAB">
%insert code here
</pre>


















































Luigi Giaccari Reply:
October 16th, 2009 at 22:57
To get the normals of triangles you don’t need to have normals in points.
If you have Matlab R2009a you can use the computational geometry toolbox to get a conform outward normal for each triangle. There is a built in function.
To get your own code you need to compute the nomral for one triangle (use cross product) and then perform a propagation on the neighborhood triangles keeping the orientation of normals. It is not the easiest thing but not even the most diffucult, try it and let me know.
Luigi
[Reply]