measuringDirection function
The measuring direction u (spec 11 D6), a world unit vector, of a
dimension of kind from world point p0 to world point p1 in a group
whose local-to-world transform is m:
- aligned:
(p1 − p0) / |p1 − p0|when|p1 − p0| > wallJoin.linear; otherwisem's local x in world, normalised (R-8: a degenerate aligned pair still lays out); - horizontal:
m's local x in world, normalised; - vertical:
m's local y in world, normalised.
Linear axes are the group's own (decision 17): world x and y while the
group is at the identity, turning with it under a rotation. The one
definition every caller uses (the plan's Ruling 11-3): the layout, the
placement function, and decision 19's choice (decideEnd).
Implementation
Vector2 measuringDirection(DimKind kind, Vector2 p0, Vector2 p1, Transform2 m) {
switch (kind) {
case DimKind.aligned:
final d = p1 - p0;
final len = d.length;
if (len > wallJoin.linear) return d / len;
return m.transformDirection(Vector2(1, 0)).normalized();
case DimKind.horizontal:
return m.transformDirection(Vector2(1, 0)).normalized();
case DimKind.vertical:
return m.transformDirection(Vector2(0, 1)).normalized();
}
}