Triangle Triangle Contact

Determines whether two triangles are touching
Updated 12 Sep 2012

View License

This is a translation of the triangle overlap code found in the UNC-CH RAPID package. It has not been overly optimized for Matlab. The triangles are of the form

t1 = [v1x, v1y, v1z;
v2x, v2y, v2z;
v3x, v3y, v3z ]

Here is a snippet of test code

%% test triangle collision code

hold on;
set(gcf, 'Renderer', 'zbuffer')
t1 = [1,1,1; 1,2,1; 2,2,2];
patch( t1(:,1), t1(:,2), t1(:,3), [0.5,0.5,0.5] )

t2 = [1.5,1.5,1.5; 1.2,3,-1; 0.5,2.4,1.0];
patch( t2(:,1), t2(:,2), t2(:,3), [0.75,0.5,0.5] )

t3 = [2.5,3.5,3.5; 1.2,3,-1; 0.5,2.4,1.0];
patch( t3(:,1), t3(:,2), t3(:,3), [0.5,0.75,0.5] )

t4 = [-1.1,-1,-1; -1,-2,-1; -2,-2,-2];
patch( t4(:,1), t4(:,2), t4(:,3), [0.5,0.5,0.75] )

result = [triTriContact( t1, t2 ), triTriContact( t1, t3 ), triTriContact( t2, t3 ), triTriContact( t1, t4 ),triTriContact( t2, t4 )]

Cite As

David Johnson (2024). Triangle Triangle Contact (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes