Java tutorial
//package com.java2s; public class Main { public static float angleInDegrees(float ownerRotation, float x1, float y1, float x2, float y2) { return Math.abs(ownerRotation - angleInDegrees(x1, y1, x2, y2)) % 360; } public static float angleInDegrees(float originX, float originY, float targetX, float targetY) { return (float) Math.toDegrees(Math.atan2(targetY - originY, targetX - originX)); } }