Here you can find the source of angle(double x1, double y1, double x2, double y2)
public static double angle(double x1, double y1, double x2, double y2)
//package com.java2s; //License from project: Open Source License public class Main { public static double angle(double x1, double y1, double x2, double y2) { return Math.atan2(y2 - y1, x2 - x1); }/*from w ww. j av a 2 s . c om*/ }