WIP: found collision position

This commit is contained in:
2025-12-28 11:38:14 -08:00
parent bb193630b9
commit 790c267957

View File

@@ -88,6 +88,8 @@
#lines circle {
fill: purple;
opacity: 0.2;
r: 5px;
}
</style>
@@ -758,7 +760,7 @@
const baseVelIntxn = lineIntxnPt(baseLine, velocityLine);
const baseSegLength = distance(baseNrmlIntxn.x, baseNrmlIntxn.y , baseVelIntxn.x, baseVelIntxn.y);
const normalSegLength = distance(baseNrmlIntxn.x, baseNrmlIntxn.y, s.position.x, s.position.y);
console.log("distance", distance(baseNrmlIntxn.x, baseNrmlIntxn.y , baseVelIntxn.x, baseVelIntxn.y));
console.log("distance", baseSegLength);
const theta = Math.atan(normalSegLength / baseSegLength);
console.log("theta", theta);
// const contactPos = { x: Math.acos() }
@@ -786,6 +788,19 @@
g.appendChild(el);
g.appendChild(star);
linesContainer.appendChild(g);
const cl = document.createElementNS(namespaceURIsvg, 'line');
cl.setAttribute('x1', baseVelIntxn.x);
cl.setAttribute('y1', baseVelIntxn.y);
cl.setAttribute('x2', s.position.x);
cl.setAttribute('y2', s.position.y);
const clPt = cl.getPointAtLength(h);
console.log(clPt);
star.setAttribute('cx', clPt.x);
star.setAttribute('cy', clPt.y);
return g;
});
}

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 35 KiB