Java tutorial
//package com.java2s; public class Main { /** * converts cartesian coordinates (positive Y is down, positive X is right) * into an angle in degrees (0 degrees is up, clockwise is positive). The * angle is between 0 and 359, inclusive. * * @param x * @param y * @return */ public static int toAngle(int x, int y) { return (int) ((Math.toDegrees(Math.atan2(y, x)) + 90) % 360); } }