Fix bound s between 0 and 1

This commit is contained in:
2026-01-05 09:05:30 -08:00
parent b3f6d79c01
commit d9ab0fa1fd

View File

@@ -209,6 +209,7 @@
const s = {
position: { x: 0, y: 0 },
velocity: { x: 0, y: 0 },
// velocity: { x: -100, y: -100 },
// velocity: { x: 5, y: 7 },
// velocity: { x: 5*mult, y: 8*mult },
@@ -916,7 +917,7 @@
const positionSeg = { xa: x, ya: y, xb: xc, yb: yc };
// console.log("positionSeg", positionSeg);
console.log("positionSeg", positionSeg);
const edgeCollision = efs.find(({ edge, wall }) => {
const { xa, ya, xb, yb } = edge;
@@ -941,15 +942,10 @@
const roundedT = +t.toFixed(2);
const roundedS = +s.toFixed(2);
console.log("positionSeg", positionSeg);
console.log("edgeSeg", edgeSeg);
console.log("s", roundedS, "t", roundedT);
// return roundedS >= 0 && roundedS <= 1 && roundedT >= 0 && roundedT <= 1;
return roundedS <= 1 && roundedT >= 0 && roundedT <= 1;
// return roundedS >= 0 && roundedS <= 1 && roundedT <= 1;
// return roundedS >= 0 && roundedS <= 1 && roundedT <= 1;
// return false;
return roundedS >= 0 && roundedS <= 1 && roundedT >= 0 && roundedT <= 1;
});
efs.forEach(({ edge, wall }) => {

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 44 KiB