diff --git a/html/images/space.svg b/html/images/space.svg
index fca9026..a1e02e2 100644
--- a/html/images/space.svg
+++ b/html/images/space.svg
@@ -193,8 +193,9 @@
const s = {
position: { x: 0, y: 0 },
- velocity: { x: 5, y: -10 },
- // velocity: { x: 5*mult, y: -10*mult },
+ // velocity: { x: 5, y: -10 },
+ // velocity: { x: -5*mult, y: 10*mult },
+ velocity: { x: -5*mult, y: 10*mult },
// velocity: { x: 0, y: -10 },
// velocity: { x: 10, y: 10 },
// velocity: { x: -10, y: -10 },
@@ -853,8 +854,11 @@
current = s.collision;
// s.collision = detectCollisions(position, allWallCorners, collE);
s.collision = cwcd.find(c => {
- const d = distance(c.corner.x, c.corner.y, xc, yc);
+ const positionSegLength = distance(xc, yc, x, y);
+ if (!positionSegLength) return false;
+
+ const d = distance(c.corner.x, c.corner.y, xc, yc);
const positionSeg = { xa: xc, ya: yc, xb: x, yb: y };
const slopeps = slope(positionSeg);
const posNormIntxn = perpIntxn(slopeps, x, y, c.corner.x, c.corner.y);
@@ -866,8 +870,15 @@
const s = ((x3-x1)*(y4-y3)-(x4-x3)*(y3-y1))/((x2-x1)*(y4-y3)-(x4-x3)*(y2-y1));
const t = -((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/((x2-x1)*(y4-y3)-(x4-x3)*(y2-y1));
+ const roundedT = +t.toFixed(2);
- return d <= shipRadius || (s >= 0 && t <= 1);
+ console.log("corner", c.corner);
+ console.log("positionSeg", positionSeg);
+ console.log("cornerSeg", cornerSeg);
+ console.log("s", s, "t", t);
+ console.log("d", d, "shipRadius", shipRadius);
+
+ return d <= shipRadius || (s >= 0 && roundedT <= 1);
});
// legs.style.display = !legs.style.display || legs.style.display === "none" ? "initial" : "none";