class Vect2d {
  double x, y;

  Vect2d() {
    x = 0;
    y = 0;
  }

  Vect2d(int ix, int iy) {
    x = ix;
    y = iy;
  }

  Vect2d(double ix, double iy) {
    x = ix;
    y = iy;
  }

  void add(Vect2d other) {
    x += other.x;
    y += other.y;
  }

  void sub(Vect2d other) {
    x -= other.x;
    y -= other.y;
  }

  int getEndX(int ox) {
    return (int)x + ox;
  }

  int getEndY(int oy) {
    return (int)y + oy;
  }

  double getDir() {
    return Math.atan2(x, y);
  }

  void scale(int str) {
    double dist, dir;

    dist = Math.pow(x, 2) + Math.pow(y, 2);
    dir = Math.atan2(x, y);

    if(dist == 0)
      return;

    x = -(str * Math.sin(dir))/dist;
    y = -(str * Math.cos(dir))/dist;
  }

  void mod(double ix, double iy) {
    x = ix;
    y = iy;
  }
}

