import { tetrahedron_compute_quality } from "./tetrahedron_compute_quality.js";

/**
 * Mesh-form wrapper for {@link tetrahedron_compute_quality}: fetches the 4
 * vertex IDs of `tet` and forwards to the indexed primitive.
 *
 * Sibling of {@link compute_tetrahedron_volume}; same convention (the
 * `compute_*` prefix marks the mesh-bound form, the `tetrahedron_compute_*`
 * prefix marks the indexed primitive).
 *
 * @param {TetrahedralMesh} mesh
 * @param {ArrayLike<number>} points flat (x,y,z) positions
 * @param {number} tet
 * @returns {number} quality in [0, 1]
 */
export function compute_tetrahedron_quality(mesh, points, tet) {
    const a = mesh.getVertexIndex(tet, 0);
    const b = mesh.getVertexIndex(tet, 1);
    const c = mesh.getVertexIndex(tet, 2);
    const d = mesh.getVertexIndex(tet, 3);
    return tetrahedron_compute_quality(points, a, b, c, d);
}
