Re: determine if point is in a volume
- From: John D'Errico <woodchips@xxxxxxxxxxxxxxxx>
- Date: Sat, 27 May 2006 02:04:50 GMT
In article <ef37bec.0@xxxxxxxxxxxxxxxx>, helper <spam@xxxxxxxxxx> wrote:
pinpress wrote:
Hello,
Can any one give some hint how to efficiently determine if a 3D
point
is inside a 3D volume specified by a surface triangular mesh? In
2D,
I can simply use "inpolygon". If we know for sure and in advnace
that the 3D volume is a convex, maybe I can use tsearch and
calculate
where the point is relative to its closest triangle. Or, just ust
inpolygon 3 times for each of the 3 projections onto xy,yz and zx
planes. However, how do I solve this problem more generally?
Thanks
a lot!
Use GRIDDATAN. If the value is NaN, it is not in the volume. If it
is non-NaN, it is.
Use of griddatan is very inefficient here. It
computes a delaunay triangulation, then calls
tsearchn, then interpolates.
You could improve this slightly by dropping
the interpolation step. Call delaunayn yourself,
then call tsearchn, which will identify points
as inside the tessellation directly.
Far better is to use inhull, which does not do
a delaunay tessellation. Instead it uses a
convex hull. If you already have the triangular
mesh, AND it is a convex mesh, then inhull will
be immensely faster. Even if you use a convex
hull first and do not have the mesh, inhull will
still be much faster, as this example shows:
n = 500;
m = 100;
p = 5;
xyz = rand(m,p);
testpts = rand(n,p)-.1;
tic
tess = delaunayn(xyz);
in0 = ~isnan(tsearchn(xyz,tess,testpts));
toc
tic
in1 = inhull(testpts,xyz);
toc
tsearchn: Elapsed time is 641.046321 seconds.
inhull: Elapsed time is 1.826386 seconds.
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=10226&objectType=FILE
In any case, with griddatan, tsearchn, or inhull,
the volume MUST be convex. ABSOLUTELY.
If the volume contained in the mesh is not convex,
then you have a problem. An alpha shape can help
solve it, but there is no 3d alpha shape (that I
know of) implementation in matlab that is freely
available.
HTH,
John D'Errico
--
The best material model of a cat is another, or preferably the same, cat.
A. Rosenblueth, Philosophy of Science, 1945
Those who can't laugh at themselves leave the job to others.
Anonymous
.
- Follow-Ups:
- Re: determine if point is in a volume
- From: marc laetzel
- Re: determine if point is in a volume
- References:
- determine if point is in a volume
- From: pinpress
- Re: determine if point is in a volume
- From: helper
- determine if point is in a volume
- Prev by Date: Stuff
- Next by Date: Re: for loop with cell arrays simplification
- Previous by thread: Re: determine if point is in a volume
- Next by thread: Re: determine if point is in a volume
- Index(es):
Relevant Pages
|
Loading