UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

18 lines (17 loc) 653 B
"use strict"; import { getCircumCenter } from "./tetCenter"; export function circumSphere(tetGeometry, id0, id1, id2, id3, target) { const p0 = tetGeometry.points.get(id0); const p1 = tetGeometry.points.get(id1); const p2 = tetGeometry.points.get(id2); const p3 = tetGeometry.points.get(id3); if (!(p0 && p1 && p2 && p3)) { return; } getCircumCenter(p0.position, p1.position, p2.position, p3.position, target.center); target.radius = target.center.distanceTo(p0.position); return; } export function isPointInTetCircumSphere(tetrahedron, point) { return point.distanceTo(tetrahedron.sphere.center) <= tetrahedron.sphere.radius; }