import 'dart:math';

class Vector {
  double x;
  double y;

  Vector(this.x, this.y);

  void normalize() {
    final length = sqrt((x * x) + (y * y));
    x /= length;
    y /= length;
  }

  void rotate(double radians) {
    x = x * cos(radians) - y * sin(radians);
    y = x * sin(radians) + y * cos(radians);
  }

  Vector translate(double x, double y, double length) {
    final xDist = this.x * length;
    final yDist = this.y * length;
    return Vector(x + xDist, y + yDist);
  }
}
