Get the desired angle of ARCTAN - Android java.lang

Android examples for java.lang:Math Trigonometric Function

Description

Get the desired angle of ARCTAN

Demo Code


//package com.java2s;

public class Main {
    /**//from w ww  . j  a  v a 2 s  .  c  o m
     * Convert Radians to Degrees.
     */
    public static final float TO_DEGREES = 57.2957795f;

    /**
     * Get the desired angle of ARCTAN from the given opp and adj
     */
    public static float arctan(float opp, float adj) {
        if (adj < 0.0)
            return -(float) (Math.atan(opp / adj) * TO_DEGREES);
        else
            return -(float) (Math.atan(opp / adj) * TO_DEGREES) + 180;
    }

    /**
     * 
     */
    public static float arctan(float value) {
        return -(float) (Math.atan(value) * TO_DEGREES) + 180;
    }
}

Related Tutorials