@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
27 lines (25 loc) • 1.03 kB
JavaScript
import { orient3d_fast } from "../plane/orient3d_fast.js";
/**
* Containment test, whether tetrahedron defined by A,B,C,D contains point E or not
* Implemented using planar tests on each of side of the tetrahedron
*
* NOTE: similar to https://gitlab.onelab.info/gmsh/gmsh/-/blob/master/contrib/hxt/tetMesh/src/HXTSPR.c
* We skip identity checks and bounding box checks. Identity is a waste of time when building tetrahedral mesh,
* since each inserted point will be new to the mesh, box checks are not relevant as we don't track those
*
* @param {number[]} points
* @param {number} a
* @param {number} b
* @param {number} c
* @param {number} d
* @param {number} e
* @returns {boolean}
*/
export function tetrahedron_contains_point(points, a, b, c, d, e) {
return !(
orient3d_fast(points, b, d, c, e) > 0
|| orient3d_fast(points, c, d, a, e) > 0
|| orient3d_fast(points, d, b, a, e) > 0
|| orient3d_fast(points, a, b, c, e) > 0
);
}