Vector rotate(num rads)

Source

Vector rotate(num rads) {
  num s = sin(rads);
  num c = cos(rads);
  return new Vector(x * c - y * s, x * s + y * c);
}