discontinuedPackage jet_cad_floor_plan has been discontinued and replaced by jet_cad_2d_plan.

rotatedTo function

Transform2 rotatedTo(
  1. Transform2 t,
  2. Vector2 basePoint,
  3. double degrees
)

t turned so its Rotation reads degrees (any finite number, taken modulo 360), about the insertion point t · basePoint (D7): the linear part A becomes R(θ' − θ)·A, so a mirror and a file's scale are kept; an orthonormal result at a multiple of 90° is R(θ')·S from the exact table, S the mirror or the identity, -0.0 normalised.

Implementation

Transform2 rotatedTo(Transform2 t, Vector2 basePoint, double degrees) {
  var target = degrees % 360;
  if (target < 0) target += 360;
  final p = t.transformPoint(basePoint);
  final delta = (target - rotationDegreesOf(t)) * math.pi / 180;
  final cs = math.cos(delta), sn = math.sin(delta);
  var a = cs * t.a - sn * t.b, b = sn * t.a + cs * t.b;
  var c = cs * t.c - sn * t.d, d = sn * t.c + cs * t.d;
  if (target % 90 == 0 && isOrthonormal(Transform2(a, b, c, d, 0, 0))) {
    final (qc, qs) = _quarter(target ~/ 90);
    if (t.a * t.d - t.b * t.c < 0) {
      // R(θ')·scale(−1, 1).
      a = -qc;
      b = -qs;
    } else {
      a = qc;
      b = qs;
    }
    c = -qs;
    d = qc;
  }
  final e = p.x - (a * basePoint.x + c * basePoint.y);
  final f = p.y - (b * basePoint.x + d * basePoint.y);
  return Transform2(
      _clean(a), _clean(b), _clean(c), _clean(d), _clean(e), _clean(f));
}