Tuple2D extends Point2D.Double implements ILocated2D { public double angle() { double angle = x == 0 ? Math.PI / 2 : Math.acos(Math.abs(this.normalize().x)); if (x < 0) { if (y < 0) { angle = Math.PI + angle; } else if (y > 0) { angle = Math.PI - angle; } else if (y == 0) { angle = Math.PI; } } else if (x > 0) { if (y < 0) { angle = (2 * Math.PI) - angle; } } else { if (y < 0) { angle = (3 * Math.PI) / 2; } else if (y > 0) { angle = Math.PI / 2; } else { angle = 0; } } return angle; } Tuple2D(double x, double y); boolean isZero(); double length(); Tuple2D normalize(); double angle(); Tuple2D midpoint(Tuple2D position); Tuple2D add(Tuple2D position); Tuple2D sub(ILocated2D rhs); Tuple2D mult(double i); Tuple2D div(double i); Tuple2D getPosition(); Tuple2D rotate(double radians); double distance(ILocated2D other); @Override String toString(); double angleBetweenTargets(ILocated2D a, ILocated2D b);  }
@Test public void testAngle() { Tuple2D test = new Tuple2D(1, 1); assertEquals(test.angle(), Math.PI / 4, ERROR); }