Newton's Preposterous Miscalculation

    triangle-triangle-intersection

    0.0.22 • Public • Published

    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

    stonks

    Install

    npm i triangle-triangle-intersection

    DownloadsWeekly Downloads

    8

    Version

    0.0.22

    License

    CC0-1.0

    Unpacked Size

    10 kB

    Total Files

    4

    Last publish

    Collaborators

    • stonkpunk