Here you can find the source of getAngle(Point2D startPosition, Point2D endPosition)
public static double getAngle(Point2D startPosition, Point2D endPosition)
//package com.java2s; /**// w w w .j av a2 s . c om * Copyright Tao, All Rights Reserved. * Confidential, do not distribute. * * Any source code displaying this header must * be considered closed source and confidential * until the project is released under an open * source license. */ import java.awt.geom.Point2D; public class Main { public static double getAngle(Point2D startPosition, Point2D endPosition) { double deltaX = endPosition.getX() - startPosition.getX(); double deltaY = endPosition.getY() - startPosition.getY(); return Math.atan2(deltaY, deltaX); } }