B2G/gecko/browser/devtools/tilt/TiltWorkerPicker.js
// (simplified) algorithm by Tomas Moller and Ben Trumbore
(simplified) algorithm by Tomas Moller and Ben Trumbore
( simplified ) algorithm by Tomas Moller and Ben Trumbore
function intersect(aVert0, aVert1, aVert2, aRay, aDest) {
    let dir = aRay.direction;
    let orig = aRay.origin;
    subtract(aVert1, aVert0, edge1);
    subtract(aVert2, aVert0, edge2);
    cross(dir, edge2, pvec);
    let inv_det = 1 / dot(edge1, pvec);
    subtract(orig, aVert0, tvec);
    let u = dot(tvec, pvec) * inv_det;
    if (u < 0 || u > 1) {
      return false;
    }
    cross(tvec, edge1, qvec);
    let v = dot(dir, qvec) * inv_det;
    if (v < 0 || u + v > 1) {
      return false;
    }
    let t = dot(edge2, qvec) * inv_det;
    scale(dir, t, lvec);
    add(orig, lvec, aDest);
    return true;
  }
function intersect ( aVert0 , aVert1 , aVert2 , aRay , aDest ) { let dir = aRay . direction ; let orig = aRay . origin ; subtract ( aVert1 , aVert0 , edge1 ) ; subtract ( aVert2 , aVert0 , edge2 ) ; cross ( dir , edge2 , pvec ) ; let inv_det = 1 / dot ( edge1 , pvec ) ; subtract ( orig , aVert0 , tvec ) ; let u = dot ( tvec , pvec ) * inv_det ; if ( u < 0 || u > 1 ) { return false ; } cross ( tvec , edge1 , qvec ) ; let v = dot ( dir , qvec ) * inv_det ; if ( v < 0 || u + v > 1 ) { return false ; } let t = dot ( edge2 , qvec ) * inv_det ; scale ( dir , t , lvec ) ; add ( orig , lvec , aDest ) ; return true ; }
(simplified) algorithm by Tomas Moller and Ben Trumbore
( simplified ) algorithm by Tomas Moller and Ben Trumbore
// find vectors for two edges sharing vert0 // begin calculating determinant - also used to calculate the U parameter // if determinant is near zero, ray lines in plane of triangle // calculate distance from vert0 to ray origin // calculate U parameter and test bounds // prepare to test V parameter // calculate V parameter and test bounds // calculate T, ray intersects triangle