Here you can find the source of getAngle(Point2D origin, Point2D target)
public static double getAngle(Point2D origin, Point2D target)
//package com.java2s; /*/* ww w.ja v a2s .c o m*/ * Copyright (c) 2014 tabletoptool.com team. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html * * Contributors: * rptools.com team - initial implementation * tabletoptool.com team - further development */ import java.awt.geom.Point2D; public class Main { public static double getAngle(Point2D origin, Point2D target) { double angle = Math.toDegrees(Math.atan2((origin.getY() - target.getY()), (target.getX() - origin.getX()))); if (angle < 0) { angle += 360; } return angle; } }