Find determinant
This commit is contained in:
@@ -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 |
Reference in New Issue
Block a user