point To Angle - Java 2D Graphics

Java examples for 2D Graphics:Angle

Description

point To Angle

Demo Code


//package com.java2s;

public class Main {

    public static double pointToAngle(double x, double y, double mCenterX,
            double mCenterY) {
        double deltaY = y - mCenterY;
        double deltaX = x - mCenterX;
        if (deltaX < 0) {
            return 180d + Math.atan(deltaY / deltaX) / Math.PI * 180;
        } else {//from  ww  w.j av a  2s  .c  o  m
            return Math.atan(deltaY / deltaX) / Math.PI * 180;
        }
    }
}

Related Tutorials