Checkpoint cover segment legality

This commit is contained in:
2026-06-05 15:15:47 +02:00
parent ac382a6cac
commit fd608ba217
2 changed files with 14 additions and 2 deletions
+13 -1
View File
@@ -679,7 +679,7 @@ function scoreSupportedPoint(candidate, previous, tangent, supportTangent, angle
supportError = closestDistance - bundleSpacing;
} else {
const floor = coverTopYAtX(candidate.x) + coverClearance(bundleCount);
supportViolation = Math.max(0, floor - candidate.y);
supportViolation = coverSegmentViolation(previous, candidate, bundleCount);
if (!allowViolation && supportViolation > 0.00001) return Number.POSITIVE_INFINITY;
supportError = candidate.y - floor;
}
@@ -693,6 +693,18 @@ function scoreSupportedPoint(candidate, previous, tangent, supportTangent, angle
return Math.abs(supportError) * 1200 + supportViolation * 100000 + backward * 100000 + supportAlignment * 0.85 + bend * 0.22 + angleDelta * 0.04 + outwardTarget * 0.01 + targetHeight * 0.006;
}
function coverSegmentViolation(previous, candidate, bundleCount) {
const clearance = coverClearance(bundleCount);
let violation = 0;
for (let sample = 1; sample <= 6; sample += 1) {
const t = sample / 6;
const x = THREE.MathUtils.lerp(previous.x, candidate.x, t);
const y = THREE.MathUtils.lerp(previous.y, candidate.y, t);
violation = Math.max(violation, coverTopYAtX(x) + clearance - y);
}
return Math.max(0, violation);
}
function closestPointOnPolyline(point, polyline) {
let best = polyline[0];
let bestDistance = Number.POSITIVE_INFINITY;
+1 -1
View File
@@ -74,6 +74,6 @@
<button id="fast_forward" type="button">Fast Forward</button>
<output id="flip_count">0 / 10</output>
</div>
<script type="module" src="/js/webgl-book-shape-lab.js?v=task2-grid-aligned-1"></script>
<script type="module" src="/js/webgl-book-shape-lab.js?v=cover-segment-floor-1"></script>
</body>
</html>