discontinuedPackage jet_cad_floor_plan has been discontinued and replaced by jet_cad_2d_plan.

tableLabelStamp function

({double rotation, double widthFactor}) tableLabelStamp(
  1. Transform2 placement
)

The rotation and width factor that make a label owned by an instance placed by placement read left to right, unmirrored, along world +x (T10). The only place this is computed.

With the linear part's columns (a, b), (c, d), φ = atan2(b, a): a proper placement (det > 0) takes rotation −φ and width factor +1; a mirrored one takes φ + π and −1, since a reflection is R(φ) · diag(1, −1) and the text's own map is R(rot) · diag(wf, 1). The rotation is normalised to (−π, π], and 0.0 is stored for −0.0.

Implementation

({double rotation, double widthFactor}) tableLabelStamp(Transform2 placement) {
  final phi = math.atan2(placement.b, placement.a);
  final det = placement.a * placement.d - placement.b * placement.c;
  final mirrored = det < 0;
  var rotation = mirrored ? phi + math.pi : -phi;
  if (rotation > math.pi) rotation -= 2 * math.pi;
  if (rotation <= -math.pi) rotation += 2 * math.pi;
  if (rotation == 0) rotation = 0.0;
  return (rotation: rotation, widthFactor: mirrored ? -1.0 : 1.0);
}