In article <eeb6843.1@WebX.raydaftYaTP>, "Darryl D'Lima"
<dd'lima@scrippsclinic.com> wrote:
> Is there an easy method in Matlab to extract the outline of an object
> made up to triangular facets? What I want is to simulate the
> projection of a 3D object and extract its silhouette. In its
> simplest form, I can compute the 2D projection of the 3D triangles
> making up the facets of the object. Then use any of the Matlab
> functions fill, patch, etc to plot the triangles. Extract the image
> data from the plot and run an edge detection. The catch is Matlab
> takes several seconds to display the plot on my 1 GHz PIII (since my
> object has thousands of triangles). And I need to do this several
> hundred times in my algorithm. So I was hoping to be able to
> directly extract the edges of the triangles that make up the
> silhouette of the 3D image or the perimeter of the 2D projection. I
> have searched the archives and even looked up some 3D computer
> graphics texts. Although I found some interesting information on
> raytracing and hidden line removal algorithms I could not find any
> efficient method of just detecting the edges of the silhouette.
Yes, it is possible to do. Is it easy? That depends
on your skill at matlab. I can give you an outline of
my code, which runs quite rapidly, although I am also
sure that other variations on my code are quite possible.
I do know that everything I do in my code is vectorized.
I assume that you have a complex composed of tetrahedra.
I have not assumed they form a convex object in 3d.
A projection of a 3d shape into a plane requires a
definition of the plane. What is important here is
the normal to that plane. Thus, projection into the
xy plane means the normal to that plane is [0 0 1].
1. List all faces of every simplex.
2. Using sort and then sortrows, sort the faces,
so that pairs of shared faces fall consecutively
in the list of all faces.
3. Each shared face is internal to the tessellation,
so delete the shared faces. What remain are the
surface faces.
4. Form the normal to each face. Use cross.
5. Ensure the face normals point outward from the
object. Use knowledge of the original tetrahedron
the face belongs to to orient the normals properly.
6. Determine whether a given face is "seen" by the
observer. Is the dot product of the projection
plane normal with the face normals for each surface
face positive? If so, then that face is potentially
visible. Keep only those faces with a positive DP.
7. Project all the vertices in the tessellation into
the plane of interest.
At this point, you have a reasonably small set of
triangles, projected into the plane of interest. Think
of the approach as hidden face removal. Some of the
triangles may overlap others, this is only a problem
if the original tessellation was not a convex one.
What I have not shown you how to do is how to deal
with the case of overlap. My approach is to compute
a set union of a list of triangles in the plane,
some of which may overlap. (It helps that I have
union, intersection and set difference operators
written for a general complex in 2 or 3d. This part
takes some work.)
HTH,
John D'Errico

