Java Angle angleFromDirection(float dirX, float dirY)

Here you can find the source of angleFromDirection(float dirX, float dirY)

Description

angle From Direction

License

Open Source License

Declaration

public static float angleFromDirection(float dirX, float dirY) 

Method Source Code

//package com.java2s;

public class Main {
    public static float angleFromDirection(float dirX, float dirY) {
        if (dirX == 0f) {
            return 0f;
        }//from   w w  w  .  j a v a2s  .  com

        float inv = dirY / dirX;
        float ang = (float) Math.atan(inv);

        // Extra half rotation if we're past 180
        if (dirX < 0) {
            ang += (float) Math.PI;
        }

        // Offset so that angle of 0 is straight up
        ang -= (float) Math.PI * 0.5f;

        return ang;
    }
}

Related

  1. angle360Limit(float angle)
  2. angleAdd(int i, final int i1)
  3. angleDistance(double angle1, double angle2)
  4. angleEquals(double angle1, double angle2, double epsilon)
  5. AngleEvaluation(double angle, int effectIndex, int angleNeeded, int orbValue)
  6. angleFromR(final double[][] R)
  7. angleInDegrees(float ownerRotation, float x1, float y1, float x2, float y2)
  8. angleInRadians(float originX, float originY, float targetX, float targetY)
  9. angleInRange(double angle, double min, double max)