@Test public void testGetAngleToVector() { Vector2D vector1 = new Vector2D(0, 0); Vector2D vector2 = new Vector2D(5, 5); double angle = vector1.getAngleToVector(vector2); double expectedAngle = Math.PI * .25; Assert.assertEquals(angle, expectedAngle); }
public double getAngleToVector(Vector2D vector2D) { Double angle = Double.NEGATIVE_INFINITY; if (!vector2D.equals(this)) { double xDist = vector2D.getXCoordinate() - xCoordinate; double yDist = vector2D.getYCoordinate() - yCoordinate; angle = java.lang.Math.atan2(yDist, xDist); } return angle; }
Vector2D { public double getAngleToVector(Vector2D vector2D) { Double angle = Double.NEGATIVE_INFINITY; if (!vector2D.equals(this)) { double xDist = vector2D.getXCoordinate() - xCoordinate; double yDist = vector2D.getYCoordinate() - yCoordinate; angle = java.lang.Math.atan2(yDist, xDist); } return angle; } }
Vector2D { public double getAngleToVector(Vector2D vector2D) { Double angle = Double.NEGATIVE_INFINITY; if (!vector2D.equals(this)) { double xDist = vector2D.getXCoordinate() - xCoordinate; double yDist = vector2D.getYCoordinate() - yCoordinate; angle = java.lang.Math.atan2(yDist, xDist); } return angle; } Vector2D(Vector2D vector2D);  Vector2D(double x, double y); }
Vector2D { public double getAngleToVector(Vector2D vector2D) { Double angle = Double.NEGATIVE_INFINITY; if (!vector2D.equals(this)) { double xDist = vector2D.getXCoordinate() - xCoordinate; double yDist = vector2D.getYCoordinate() - yCoordinate; angle = java.lang.Math.atan2(yDist, xDist); } return angle; } Vector2D(Vector2D vector2D);  Vector2D(double x, double y); @Override boolean equals(Object o); @Override int hashCode(); double getYCoordinate(); double getXCoordinate(); @Override String toString(); Vector2D getVectorInDirection(double distance, double angle); double getAngleToVector(Vector2D vector2D); double getDistanceToVector(Vector2D vector2D); double getSquaredDistanceToVector(Vector2D vector2D); }
Vector2D { public double getAngleToVector(Vector2D vector2D) { Double angle = Double.NEGATIVE_INFINITY; if (!vector2D.equals(this)) { double xDist = vector2D.getXCoordinate() - xCoordinate; double yDist = vector2D.getYCoordinate() - yCoordinate; angle = java.lang.Math.atan2(yDist, xDist); } return angle; } Vector2D(Vector2D vector2D);  Vector2D(double x, double y); @Override boolean equals(Object o); @Override int hashCode(); double getYCoordinate(); double getXCoordinate(); @Override String toString(); Vector2D getVectorInDirection(double distance, double angle); double getAngleToVector(Vector2D vector2D); double getDistanceToVector(Vector2D vector2D); double getSquaredDistanceToVector(Vector2D vector2D); static final Vector2D ORIGIN; }