wallEndPoint function
Wall w's point at end k (0 its start, 1 its end) on side, among
others, its wall neighbours (w itself and degenerate walls are
ignored, as in classify) (spec 11 D4):
- centre: the stored centreline end,
w.endpoint(k)(R-4): the end of the centreline polyline the wall generates, so what a snap finds. At an L it is the node point; at a T butt the stem's end on the through wall's centreline, inside the through wall's band. - left / right: the first or last point of the wall's drawn cap
at that end (drawnCapsOf, which takes 07's two fallbacks, R-5). A cap
runs from the end's outgoing-left face to its outgoing-right face,
looking out of the wall along the end's outgoing direction. At the
start (
k = 0) that direction is the wall's own, so outgoing-left is the wall's left; at the end (k = 1) it is reversed, so outgoing-left is the wall's right. So the wall's left point isstartCap.firstorendCap.last, and its right pointstartCap.lastorendCap.first. A node owner's cap walks its lobe, but its first and last points are still its own corners. - A degenerate wall (07 D2) has no outline: every side is its centreline end.
Implementation
Vector2 wallEndPoint(
WorldWall w, List<WorldWall> others, int k, WallSide side) {
if (side == WallSide.centre || w.degenerate) return w.endpoint(k);
final caps = drawnCapsOf(w, others)!;
final c = k == 0 ? caps.startCap : caps.endCap;
final outgoingLeft = (k == 0) == (side == WallSide.left);
return outgoingLeft ? c.first : c.last;
}