calculateRotatedSize static method

Point<double> calculateRotatedSize(
  1. double rotation,
  2. Point<double> nonRotatedSize
)

Calculates the size of a bounding box which surrounds a box of size nonRotatedSize which is rotated by rotation.

Implementation

static Point<double> calculateRotatedSize(
  double rotation,
  Point<double> nonRotatedSize,
) {
  if (rotation == 0.0) return nonRotatedSize;

  final rotationRad = degrees2Radians * rotation;
  final cosAngle = math.cos(rotationRad).abs();
  final sinAngle = math.sin(rotationRad).abs();
  final width = (nonRotatedSize.x * cosAngle) + (nonRotatedSize.y * sinAngle);
  final height =
      (nonRotatedSize.y * cosAngle) + (nonRotatedSize.x * sinAngle);

  return Point<double>(width, height);
}