fix: keep island contact polygon inside boundary
This commit is contained in:
1 parent
95b8f068aa
commit
3ed503a986
2 files changed
+29
-3
No files matched your search
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { union } = require('./junction-polygon-ops');
|
||||
|
||||
function buildPedestrianIsland({ key, ring, crossingKeys, provenance = 'inferred' }) {
|
||||
if (!key || !Array.isArray(ring) || ring.length < 4) return null;
|
||||
const adjacentCrossings = [...new Set(crossingKeys || [])];
|
||||
@@ -173,9 +175,12 @@ function solveIslandContacts(firstSegment, secondSegment, thirdWidth, options =
|
||||
// roundover is pushed away from that vertex so the island does not intrude
|
||||
// into the vehicle swept area behind the two perpendicular crossings.
|
||||
const hypotenuseMidpoint = midpoint(contacts[1][1], contacts[2][0]);
|
||||
const hypotenuseControl = hypotenuseMidpoint.map((value, axis) => value * 0.55 + corner[axis] * 0.45);
|
||||
const hypotenuseControl = hypotenuseMidpoint.map((value, axis) => value * 1.45 - corner[axis] * 0.45);
|
||||
const innerMidpoint = midpoint(contacts[2][1], contacts[0][0]);
|
||||
const innerControl = innerMidpoint.map((value, axis) => value * 1.35 - corner[axis] * 0.35);
|
||||
// Keep the right-angle roundover outside the crossing intersection. Its
|
||||
// control point is deliberately beyond the contact chord, leaving the
|
||||
// vehicle-side edge at least one crossing half-depth from the corner.
|
||||
const innerControl = innerMidpoint.map((value, axis) => value * 4 - corner[axis] * 3);
|
||||
const controls = [firstTip, hypotenuseControl, innerControl];
|
||||
const steps = 16;
|
||||
contacts.forEach((contact, index) => {
|
||||
@@ -191,11 +196,14 @@ function solveIslandContacts(firstSegment, secondSegment, thirdWidth, options =
|
||||
}
|
||||
});
|
||||
ring.push(ring[0]);
|
||||
const greenRing = [...vertices, vertices[0]];
|
||||
const merged = union(ring, greenRing);
|
||||
if (merged.length === 1 && merged[0].length === 1) ring.splice(0, ring.length, ...merged[0][0]);
|
||||
return {
|
||||
status: 'solved',
|
||||
reason: null,
|
||||
ring,
|
||||
greenRing: [...vertices, vertices[0]],
|
||||
greenRing,
|
||||
contacts,
|
||||
thirdContact,
|
||||
thirdCenter,
|
||||
|
||||
Reference in new issue
Block a user