This commit is contained in:
2026-01-07 15:39:27 -08:00
parent b9884ba077
commit b81f0a8565

View File

@@ -699,26 +699,13 @@
}
function cornerContactPosition(xc, yc, x, y, corner, cLength) {
const diffx = xc - x;
const diffy = yc - y;
// console.log("xc", xc, "yc", yc, "x", x, "y", y);
const positionSeg = { xa: xc, ya: yc, xb: x, yb: y };
const posNormIntxn = perpIntxn(slope(positionSeg), x, y, corner.x, corner.y);
const posSegLength = Math.sqrt(diffy ** 2 + diffx ** 2);
const detp = xc * y - yc * x;
// console.log("detp", detp, "posSegLength", posSegLength);
// the length of the "corner segment"
// shortest distance between corner and path
const aLength = distance(corner.x, corner.y, posNormIntxn.x, posNormIntxn.y);
// where did I get this calculation? it also works but how??
// const aLengthAlso = Math.abs(diffy * corner.x - diffx * corner.y + detp) / posSegLength;
// console.log("aLength", aLength, "aLengthAlso", aLengthAlso);
// drawLine(posNormIntxn.x, posNormIntxn.y, corner.x, corner.y, "red");
// distance from position/normal intersection
const bLength = Math.sqrt(Math.abs(cLength ** 2 - aLength ** 2));
// console.log("bLength", bLength);
const intxnSeg = document.createElementNS(namespaceURIsvg, 'line');
intxnSeg.setAttribute('x1', posNormIntxn.x);
@@ -897,10 +884,10 @@
started = false;
const mult = 10000;
s.position = { x: 2, y: 7 };
// s.velocity = { x: 4.5, y: 5 };
s.position = { x: 0, y: 0 };
s.velocity = { x: 0, y: 0 };
s. velocity = { x: 2*mult, y: 7*mult };
// s. velocity = { x: 2*mult, y: 7*mult };
s.acceleration = { x: 0, y: 0 };
s.rotate = 0;

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB