rotate method

Point rotate(
  1. double deg
)

rotate the point by deg degrees

Implementation

Point rotate(double deg) {
  final radians = deg * pi / 180.0; // Convert degrees to radians
  final cosTheta = cos(radians);
  final sinTheta = sin(radians);
  final newX = x * cosTheta - y * sinTheta;
  final newY = x * sinTheta + y * cosTheta;
  return Point(newX, newY);
}