chairAt function

List<CatalogShape> chairAt(
  1. double cx,
  2. double cy,
  3. double facing
)

A chair facing a table: its seat (a closed 450 x 450 square) centred at (cx, cy) and its back line, the table in direction facing (radians from +x). The back line is 60 in from the edge away from the table.

Implementation

List<CatalogShape> chairAt(double cx, double cy, double facing) {
  const h = chairSize / 2;
  // The chair's frame: u towards the table, v across it.
  final ux = math.cos(facing), uy = math.sin(facing);
  final vx = -uy, vy = ux;
  CatalogPoint at(double u, double v) =>
      _p(cx + u * ux + v * vx, cy + u * uy + v * vy);
  return [
    poly([at(-h, -h), at(h, -h), at(h, h), at(-h, h)]),
    CatalogLine(at(-h + _chairBack, -h), at(-h + _chairBack, h)),
  ];
}