If you can form a list of the supporting hyperplanes (that is, the
planar surfaces that form the boundary of the convex hull), then
you can. Suppose each of these planes is of the form
V'x = k
where x denotes a point in R^3, V the normal vector pointing
towards the half-space containing your data, and k the common value
of V'x along the plane.
Let W = [V_1 V_2 ... V_n] be the concatenation of all the V's
describing the supporting hyperplanes, and K = [k_1; k_2; ... k_n]
a vector containing all the k's. Then your masking function is
all(W'x >= K)
or
all(W'x - K >= 0)
for a single point x, and for a list X = [x_1 ... x_N] of points,
it's
all( bsxfun(@minus, W'X ,K) >= 0)
You'll get an array of size 1 x N containing ones for the points
within the volume, and zeros for those points not in it.
Replace >= by > for the points strictly in the interior.
BTW, I'm not sure how to get that list of hyperplanes from the
output of convhulln.m, so I'll go check on that.
Dale
I think I should be able to get the equations for the surface by taking the cross product of two of the edges of each face. However, I am not quite sure how I could be sure to only get normals that point inward. Flipping signs till the divergence is at a maximum?
On the file exchange, there is a function called vert2con.m that will essentially figure this out for you.
The normal must point in the direction opposite to the all other vertices of the hull (from the faces). Take P any vertice that belongs to the face, n exterior normal must satisfies:
<PQ,n> <= 0 for all Q in the hull.
This help you to fix the sign
Bruno
Thank you very much for the tip! It allowed me to create code to create a mask from a surface.
I am attempting to create a logical mask as well, but I do not fully understand the process you outlined above. I have the following matrices at my disposal: the hull faces (connectivity matrix), the co-ordinates of the hull vertices, the co-ordinates of the centroid of each triangle, and the normal vectors (located at the centroid of each triangle).
My main problem is that I do not understand the apostrophe notation that you used above (examples: V'x and W'x). Can you please explain what this notation means? MATLAB does not recognize it. Lastly, 'V' is an N-by-3 matrix for N normal vectors and 'x' is an M-by-3 sized matrix for M points of interest, correct?
Thank you for your help!
I am attempting to create a logical mask as well, but I do not fully understand the process you outlined above. I have the following matrices at my disposal: the hull faces (connectivity matrix), the co-ordinates of the hull vertices, the co-ordinates of the centroid of each triangle, and the normal vectors (located at the centroid of each triangle).
> I am attempting to create a logical mask as well, but I do not fully understand the process you outlined above. I have the following matrices at my disposal: the hull faces (connectivity matrix), the co-ordinates of the hull vertices, the co-ordinates of the centroid of each triangle, and the normal vectors (located at the centroid of each triangle).
============
All you need are the hull vertices to implement the solution in Message #4.
vert2con will give you equations representing the hull
A*x<=b
You can use these equations to populate your logical mask
I'm sorry - I misspoke when I described my volume as a convex hull. The volume to be masked is a model of an artery in the shape of an 'L' with closed ends. I am afraid vert2con will connect the two ends of the model and output equations for a convex hull with a shape similar to a 30-60-90 triangle (sort of like 'L\').
I know how to create a mask using the DelaunayTri class. However, as I described above, many of the vertices are incorrectly connected. This is because the hull functions create faces from the outermost points, whereas my volume requires specific connections (given by the 'faces' matrix that I described earlier).
I felt that the solution in message #4 would allow me to define a more specific and appropriate mask, but I don't understand the apostrophe notation that was being used.
Any help would be appreciated!
> I felt that the solution in message #4 would allow me to define a more specific and appropriate mask, but I don't understand the apostrophe notation that was being used.
=====
I think you mean Message #2. The apostrophe notation V'x in message #2 is V'*x, i.e., the dot product of the normal vector V to one of the face with a vector x.
Message #4 proposes the same solution as in Message #2 with the only difference being that vert2con would do much of the work in setting up the equations.
All of this is moot for you, however, because all of the techniques proposed in this thread are applicable only for a convex hull.