discontinuedPackage jet_cad_floor_plan has been discontinued and replaced by jet_cad_2d_plan.

kindFor static method

DimKind kindFor(
  1. Vector2 q,
  2. Vector2 p0,
  3. Vector2 p1, {
  4. required bool shift,
})

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_x and e_y, how far q lies outside the two points' x and y spans (0 inside); e_y > e_x is horizontal (dragged above or below), e_x > e_y vertical (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;
}