## Distance Between Two Triangles

Version 1.0.0 (1.29 KB) by
Finds the shortest distance between two triangles in 3d space.

Updated 20 Jan 2023

This function finds the shortest distance between two triangles in 3d space using nonlinear constrained optimization.
function d=Distance2Triangles(va1,va2,va3,vb1,vb2,vb3)
where:
va1 is (3*1) coordinate vector for the first vertex of triangle a.
va2 is (3*1) coordinate vector for the second vertex of triangle a.
va3 is (3*1) coordinate vector for the third vertex of triangle a.
vb1 is (3*1) coordinate vector for the first vertex of triangle b.
vb2 is (3*1) coordinate vector for the second vertex of triangle b.
vb3 is (3*1) coordinate vector for the third vertex of triangle b.
d is the shortest distance between triangle a and triangle b.

### Cite As

Ayad Al-Rumaithi (2023). Distance Between Two Triangles (https://www.mathworks.com/matlabcentral/fileexchange/123620-distance-between-two-triangles), MATLAB Central File Exchange. Retrieved .

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