kindFor static method
The kind a third point q commits for the pair p0, p1 (spec 11
D12, R-21), in world (the tool's group is the identity):
- without
shift, aligned; - with it, the side dragged to:
e_xande_y, how farqlies outside the two points' x and y spans (0 inside);e_y > e_xis horizontal (dragged above or below),e_x > e_yvertical (dragged left or right), and a tie (both 0 inside the span box included) horizontal when|dx| ≥ |dy|, else vertical; - a linear kind that would measure ≤
wallJoin.linear(a vertical pair dragged above) gives way to the other, so a non-degenerate pair never makes a zero linear dimension.
The comparisons are exact: they choose between two valid outcomes from a pointer position, and a tie has no wrong answer.
Implementation
static DimKind kindFor(Vector2 q, Vector2 p0, Vector2 p1,
{required bool shift}) {
if (!shift) return DimKind.aligned;
final ex = _outside(q.x, p0.x, p1.x), ey = _outside(q.y, p0.y, p1.y);
final dx = (p1.x - p0.x).abs(), dy = (p1.y - p0.y).abs();
final horizontal = ey > ex || (ey == ex && dx >= dy);
if (horizontal) {
return dx <= wallJoin.linear ? DimKind.vertical : DimKind.horizontal;
}
return dy <= wallJoin.linear ? DimKind.horizontal : DimKind.vertical;
}