diff --git a/html/images/space.svg b/html/images/space.svg
index ab6c7f8..73adb55 100644
--- a/html/images/space.svg
+++ b/html/images/space.svg
@@ -153,21 +153,19 @@
const delim = ' ';
const className = 'clockwise-orientation';
- 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);
+ triangles.forEach(t => {
+ const attr = t.getAttribute('points').split(delim);
+ const [[xa, ya], [xb, yb], [xc, yc]] = attr.map(t => t.split(','));
+ const det = (+xb - +xa) * (+yc - +ya) - (+xc - +xa) * (+yb - +ya);
const pos = `${positionX},${positionY}`;
- const list = triangle.classList;
- const clockwiseOrientation = det < 0;
+ const cwOrientation = det < 0;
if (pos !== attr.pop()) {
attr.push(pos);
- triangle.setAttribute('points', attr.join(delim));
+ t.setAttribute('points', attr.join(delim));
}
- clockwiseOrientation ? list.add(className) : list.remove(className);
-
+ t.classList[cwOrientation ? "add" : "remove"](className);
// i think i can also discard obtuse triangles?
// if all the triangles are obtuse, i only need to check the nearest corner for a collision