triangle-triangle-intersection
v0.0.22
Published
return line segment representing the intersection between a pair of 3D triangles. based on Thomas Möller's algorithm.
Downloads
983
Maintainers
Readme
triangle-triangle-intersection
Check if two triangles intersect.
If they intersect, returns the line segment of their intersection.
If not, returns null.
Based on Thomas Möller's algorithm
Installation
npm i triangle-triangle-intersection
Usage
var tti = require('triangle-triangle-intersection');
//each triangle is 3 pts [x,y,z]
var triangle1 = [[0,0,0],[1,0,0],[1,1,0]];
var triangle2 = [[0,0,1],[1,0,1],[1,1,-1]];
var intersection = tti(triangle1,triangle2);
console.log(intersection);
//returns line segment of intersection:
//[ [ 1, 0.5, 0 ], [ 0.5, 0.5, 0 ] ]
See Also
- triangle-distance - distance to triangle