function rotateVector(x, y, rad) {
  const X = x * Math.cos(rad) - y * Math.sin(rad);
  const Y = x * Math.sin(rad) + y * Math.cos(rad);
  return { x: X, y: Y };
}
Returns an {x,y} vector rotated by a given
angle in radian.

@param {number} x the initial vector x
@param {number} y the initial vector y
@param {number} rad the radian vector angle
@returns {{x: number, y: number}} the rotated vector