Find determinant

This commit is contained in:
2025-12-18 14:45:45 -08:00
parent 2b6fadab29
commit c3bd622841

View File

@@ -149,9 +149,14 @@
triangles.forEach(triangle => {
const attr = triangle.getAttribute('points').split(delim)
const [[xa, ya], [xb, yb], [xc, yc]] = attr.map(t => t.split(',').map(n => +n));
const det = (xb - xa) * (yc - ya) - (xc - xa) * (yb - ya);
attr.pop();
attr.push(`${positionX},${positionY}`);
triangle.setAttribute('points', attr.join(delim));
triangle.style.fill = det < 0 ? "white" : "none";
triangle.style.stroke = det < 0 ? "red" : "none";
// i think i can also discard obtuse triangles?
});
}

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB