rotateVertices function

List<Point<double>> rotateVertices(
  1. Size size,
  2. double theta
)

Implementation

List<Point<double>> rotateVertices(Size size, double theta) {
  final double cosTheta = cos(theta);
  final double sinTheta = sin(theta);

  final List<Point<double>> vertices = <Point<double>>[
    Point<double>(size.width / 2, size.height / 2),
    Point<double>(-size.width / 2, size.height / 2),
    Point<double>(-size.width / 2, -size.height / 2),
    Point<double>(size.width / 2, -size.height / 2)
  ];

  return vertices.map((Point<double> vertex) {
    final double xNew = vertex.x * cosTheta - vertex.y * sinTheta;
    final double yNew = vertex.x * sinTheta + vertex.y * cosTheta;
    return Point<double>(xNew, yNew);
  }).toList();
}