Vector reflect(Vector normal)

Source

Vector reflect(Vector normal) {
  num d = 2 * (x * normal.x + y * normal.y);
  return new Vector(x - d * normal.x, y - d * normal.y);
}