@Test public void testRotate() { Vector2 v0 = new Vector2(1.0, 0.0); Vector2 answer = v0.rotate(Math.PI / 2.0); assertEquals(0.0, answer.getX(), delta); assertEquals(1.0, answer.getY(), delta); }
public Vector2 rotate(double angle) { double x = this.getX() * Math.cos(angle) - this.getY() * Math.sin(angle); double y = this.getX() * Math.sin(angle) + this.getY() * Math.cos(angle); return new Vector2(x, y); }
Vector2 implements IsSerializable { public Vector2 rotate(double angle) { double x = this.getX() * Math.cos(angle) - this.getY() * Math.sin(angle); double y = this.getX() * Math.sin(angle) + this.getY() * Math.cos(angle); return new Vector2(x, y); } }
Vector2 implements IsSerializable { public Vector2 rotate(double angle) { double x = this.getX() * Math.cos(angle) - this.getY() * Math.sin(angle); double y = this.getX() * Math.sin(angle) + this.getY() * Math.cos(angle); return new Vector2(x, y); } Vector2();  Vector2(double x, double y); }
Vector2 implements IsSerializable { public Vector2 rotate(double angle) { double x = this.getX() * Math.cos(angle) - this.getY() * Math.sin(angle); double y = this.getX() * Math.sin(angle) + this.getY() * Math.cos(angle); return new Vector2(x, y); } Vector2();  Vector2(double x, double y); Vector2 clone(); double getX(); void setX(double x); double getY(); void setY(double y); Vector2 add(Vector2 rhs); Vector2 subtract(Vector2 nodePosition); double length(); Vector2 rotate(double angle); double distance(Vector2 other); double distanceSquared(Vector2 other); String toString(); String toJSON(); void normalize(); double dot(Vector2 v); }
Vector2 implements IsSerializable { public Vector2 rotate(double angle) { double x = this.getX() * Math.cos(angle) - this.getY() * Math.sin(angle); double y = this.getX() * Math.sin(angle) + this.getY() * Math.cos(angle); return new Vector2(x, y); } Vector2();  Vector2(double x, double y); Vector2 clone(); double getX(); void setX(double x); double getY(); void setY(double y); Vector2 add(Vector2 rhs); Vector2 subtract(Vector2 nodePosition); double length(); Vector2 rotate(double angle); double distance(Vector2 other); double distanceSquared(Vector2 other); String toString(); String toJSON(); void normalize(); double dot(Vector2 v);  }