Tutorial for SurfaceIntersection Function

Triangle/triangle intersection using the algorithm proposed by Tomas Möller (1997), implemented as highly vectorized MATLAB code. The algorithm was expanded to include calculation of the intersection surface.

[intMatrix, intSurface] = SurfaceIntersection(surface1, surface2) calculates the intersection of surfaces 1 and 2. Code can either return just the matrix indicating which face of surface1 intersected with face of surface2, which is calculated using Tomas Moller algorithm, or can also return the actual line or surface of intersection. In case when parts of the surface 1 and 2 lay on the same plane the intersection is a 2D area instead of 1D edge. In such a case the intersection area will be triangulated and intSurface.edges will hold the edges of the triangulation surface and intSurface.faces will hold the faces.

Change History

Licence

Copyright (c) 2014, Jaroslaw Tuszynski
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

25% coplanar faces.
# faces in surface 1 = 7200; # faces in surface 2 = 7200
Run time without intersection calculation is 12.934015
Run time with intersection calculation is 19.862958
Number of face pairs is 51840000 and number of intersections is 11023
Number of differences: 0

No coplanar faces.
# faces in surface 1 = 7200; # faces in surface 2 = 7200
Run time without intersection calculation is 5.702677
Run time with intersection calculation is 6.239134
Number of face pairs is 51840000 and number of intersections is 3405
Number of differences: 0